0 votes
1 view

I want to display markers from a REST data set in a Mapwidget with a geoJSON point as spatial attribute such as :

"location": {
  "type": "Point",
  "coordinates": [7.201978,43.683595]
}

I configured Coordinates Type as 'JSON', and Coordinates format to 'lon lat'

But it doesn't work, no markers are displayed on the map, can someone help with an example of a working spatial attribute in geoJSON content ?

do I need to encapsulate in an array of "features", or in a "geometry" such as :

"location":{ 
  "geometry" :{
    "type": "Point", 
    "coordinates": [7.201978,43.683595] 
   }
}

Thanks in advance for a working exemple, if geoJSON works, 

Or for an alternative solution to convert my geoJSON attribute in a string attribute "<lon> <lat>", at data set level, through a json path expression ?

Environment Knowage version 7.4.0-S, docker, chrome, all on MacOs
asked Feb 22, 2021 in Workspace by alaing (670 points)
edited Feb 22, 2021 by alaing | 1 view

I have tried with spatial attribute like :

"feature": {
  "type": "StructuredValue",
  "value": {
     "type": "Feature",
     "geometry": {
        "type": "Point",
        "coordinates": 7.253000539, 43.701089603]
      }
   }
}

I checked with OpenLayers, ol/format/GeoJSON.readFeatures, and it works with this format

but still I cant' see any marker :(

No error seen with the browser debugger...

I need a solution, even temporary, to make a demo on next wednesday morning...

thanks in advance for help

1 Answer

+1 vote
OK, I managed to have markers displayed with the "string" format "lon lat" !, but with modified NGSI entities

It means I need to have a calculated field for existing data, we read, which are using geoJSON features.

But bad luck :

1/ json path attributes definition does not support concatenation, nor formatting,

2/ and if you don't declare a spatial attribute for the data set, you can't use it in a mapWidget,

then it's impossible to change the format of the spatial attribute for adaptation, except by using a gateway (script) that retrieve and transform the data before returning the json data...

I think it's worth an issue in the knowage github project...

And what if want to display polylines (LineString) ? this is another question !
answered Feb 23, 2021 by alaing (670 points)
I use GeoJSON in map widget. Spatial attribute looks like this :
{"type":"Polygon","coordinates":[[[5.64209,47.18345],[5.64262,47.18389],[5.64209,47.18345]]]}

Hello @rlagarde,

OK, which Knowage version are you using ?

I'm curious to know, because I use 7.4.0, and I had to do some changes, in cockpitModule_mapServices.js, to be able to display geoJSON features, coming from REST data set...

also which kind of dataset are you using ?

My hack, works for geoJSON Points, LineString & Polygon., coming from a REST data set

the main reason in 7.4.0, is that the spatial attribute come in a strange format, which is not json, no quotes (") around string and "=" instead of ":"...

{"type":"Polygon","coordinates":[[[5.64209,47.18345],[5.64262,47.18389],[5.64209,47.18345]]]}
comes as :
{type=Polygon,coordinates=[[[5.64209,47.18345],[5.64262,47.18389],[5.64209,47.18345]]]}

Your answer interest me, to avoid side effects with my hack...

Thanks in advance for your kind reply

Hi alaing,

I haven't used REST datasets yet. I know it is precisely the subject of your OP.
Still I commented to let you know what spatial attribute looks like for me when using geoJSON in map widget.
Just in case it could hepl you set your JSON path expression.
I use geoJSON for polygons with chloroplet visualisation. I use Lon,Lat string for points and I'm not sure if map widget can display lines at all. Let me know if you can.
I use 7.2.16
Hi rlagarde,

It seems that there's no transformation of the geoJSON, in your use case with polygons, like it happens with REST data set...

Which kind of data set are you using, it it a query over a data source, or a file ?
Query over PostgreSQL datasource.
Column containing geoJSON is set to text in DB but is then read as geoJSON in Knowage.
I created this column for Knowage purpose only as we use WKB geometry in our apps.
1,555 questions
1,017 answers
2,038 comments
2,568 users