Skip to content

Commit

Permalink
fixed order of lon/lat coordinates in mapbox plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
s-tittel committed Feb 22, 2024
1 parent 62e5643 commit 69417b7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions demo/complex-example-data.ttl
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ example:4f2a8de3-9fc8-40a9-9237-d5964520ec54
schema:width 200 ;
dcterms:spatial [
a dcterms:Location ;
geo:asWKT "POLYGON((52.37900504575066 13.06382134836241,52.37896794299019 13.063796707503286,52.37875635638159 13.063798350228126,52.37875435081642 13.063926482692182,52.378964934657034 13.0639281254158,52.37900404297392 13.063905127281544,52.37900504575066 13.06382134836241))"^^geo:wktLiteral ;
geo:asWKT "POLYGON((13.06382134836241 52.37900504575066,13.063796707503286 52.37896794299019,13.063798350228126 52.37875635638159,13.063926482692182 52.37875435081642,13.0639281254158 52.378964934657034,13.063905127281544 52.37900404297392,13.06382134836241 52.37900504575066))"^^geo:wktLiteral ;
dcterms:description "Building has been realized here" ;
] ;
dcterms:spatial [
a dcterms:Location ;
geo:asWKT "POINT(50.09895428462539 8.681927539753275)"^^geo:wktLiteral ;
geo:asWKT "POINT(8.681927539753275 50.09895428462539)"^^geo:wktLiteral ;
dcterms:description "Model is stored here" ;
] ;
prov:qualifiedAttribution [
Expand Down
2 changes: 1 addition & 1 deletion demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<script type="importmap">
{
"imports": {
"@ulb-darmstadt/shacl-form/": "https://cdn.jsdelivr.net/npm/@ulb-darmstadt/[email protected].5/dist/"
"@ulb-darmstadt/shacl-form/": "https://cdn.jsdelivr.net/npm/@ulb-darmstadt/[email protected].6/dist/"
}
}
</script>
Expand Down
8 changes: 4 additions & 4 deletions src/plugins/mapbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export class MapboxPlugin extends Plugin {
if (pointCoords?.length == 2) {
const xy = pointCoords[1].split(' ')
if (xy.length === 2) {
return { type: 'Point', coordinates: [parseFloat(xy[1]), parseFloat(xy[0])] }
return { type: 'Point', coordinates: [parseFloat(xy[0]), parseFloat(xy[1])] }
}
}
const polygonCoords = wkt.match(/^POLYGON[(]{2}(.*)[)]{2}$/)
Expand All @@ -173,7 +173,7 @@ export class MapboxPlugin extends Plugin {
for (const coord of split) {
const xy = coord.split(' ')
if (xy.length === 2) {
outer.push([parseFloat(xy[1]), parseFloat(xy[0])])
outer.push([parseFloat(xy[0]), parseFloat(xy[1])])
}
}
return { type: 'Polygon', coordinates: coords }
Expand All @@ -183,9 +183,9 @@ export class MapboxPlugin extends Plugin {

geometryToWkt(geometry: Geometry): string {
if (geometry.type === 'Point') {
return `POINT(${geometry.coordinates.reverse().join(' ')})`
return `POINT(${geometry.coordinates.join(' ')})`
} else if (geometry.type === 'Polygon') {
return `POLYGON((${geometry.coordinates[0].map(item => { return item.reverse().join(' ') }).join(',')}))`
return `POLYGON((${geometry.coordinates[0].map(item => { return item.join(' ') }).join(',')}))`
} else {
return ''
}
Expand Down

0 comments on commit 69417b7

Please sign in to comment.