4

The data representation I will try to use for a RESTful API is JSON-LD and the vocabulary I intend to use are those from schema.org.

In the vocabulary schema.org/GeoShape, it says that polygons are expected to be on text format but it doesn't exactly say what kind of text format. It wasn't also stated that it should use the WKT Polygon format.

WKT Polygon Format (Well-known Text)

POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10))

However, since I will be representing data using JSON-LD, it may also be reasonable to use something similar with GeoJson Polygons or the native JSON Array.

GeoJson Polygon Format

{
"type": "Polygon",
"coordinates": [
        [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0] ]
    ]
}

Native JSON 2D Array

[
[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]
]

With this in mind, what is the proper value representation of a schema.org/polygon when used in JSON-LD?

Community
  • 1
  • 1
Abel Callejo
  • 13,779
  • 10
  • 69
  • 84

2 Answers2

1

I would strongly suggest to use the suggested text format as that's what most consumers will expect. If you prefer a more structured representation, you could consider using GeoJSON-LD instead: http://geojson.org/vocab

Markus Lanthaler
  • 3,683
  • 17
  • 20
  • cool! so that would be like `{ "@context" : "http://geojson.org/contexts/geojson-base.jsonld", "@type" : "Polygon", "coordinates", [ [ [100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0],[100.0, 0.0] ] ] }` – Abel Callejo May 16 '15 at 15:45
  • I tried that [GeoJSON Vocabulary](http://geojson.org/vocab) and tested the response text in [Google's Structured Data Testing Tool](https://developers.google.com/structured-data/testing-tool/). It turns out both *longitude* and *latitude* values will be interpreted as [http://example.com/vocab#coordinates](http://example.com/vocab#coordinates) – Abel Callejo May 16 '15 at 21:32
  • Which isn't surprising if you look at how http://geojson.org/contexts/geojson-base.jsonld is defined. It contains the following mapping: `"coordinates": "http://example.com/vocab#coordinates"` – Markus Lanthaler May 18 '15 at 07:36
0

the following snippet works for me in the Google testing tool https://search.google.com/test/rich-results and the Schema.org testing tool https://validator.schema.org/

"@type": "GeoShape",
        "polygon": "[GeoPoint1],[GeoPoint2],[GeoPoint3],[GeoPoint4],[GeoPoint1]"
        
Jason Herz
  • 23
  • 5