What is the proper value representation of a schema.org/polygon when used in JSON-LD?
Asked Answered
D

2

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?

Dreadful answered 11/8, 2014 at 3:31 Comment(0)
N
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

Nyctaginaceous answered 12/8, 2014 at 15:30 Comment(3)
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] ] ] }Dreadful
I tried that GeoJSON Vocabulary and tested the response text in Google's Structured Data Testing Tool. It turns out both longitude and latitude values will be interpreted as http://example.com/vocab#coordinatesDreadful
Which isn't surprising if you look at how geojson.org/contexts/geojson-base.jsonld is defined. It contains the following mapping: "coordinates": "http://example.com/vocab#coordinates"Nyctaginaceous
D
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]"
        
Donor answered 7/3, 2023 at 23:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.