Skip to main content
Question

Indoor geojson wrong structure?

  • November 9, 2018
  • 13 replies
  • 28 views

totobobiasos
Forum|alt.badge.img

Hi,

I'm trying to make an indoor map, to use with this leaflet plugin:

https://www.cbaines.net/projects/osm/leaflet-indoor/examples/

(data.json is found here: https://github.com/cbaines/leaflet-indoor/tree/master/examples)

Input data is complete indoor maps in shapefiles with offices, hallways etc. each object with room numbers. I also have a large table of all employees with name, title, organisation, phone, and room number. These get joined by room number attribute with a Databasejoiner, and because some share rooms, turned into a list attribute. So far so good.

I've tried, with very limited success, to use Jsontemplater. As I've worked with geojson only once or twice I'm at a loss how to continue. I have gotten as far as writing a geojson, but not with the right structure. Pleeeeease push me in the right direction as to setup the Jsontemplater.

(renamed from .json to .txt because of security(?))

Please

 

 

Update: Below is an example of the result json (which couldn't be accessed... hrm, well). Also attached workspace and csv file with structure of DB tabl e

 

 

 

{

 

"vpl" : {

 

"type" : "FeatureCollection",

 

"features" : [

 

{

 

"type" : "Feature",

 

"geometry" : {

 

"type" : "Polygon",

 

"coordinates" : [

 

[

 

[ 11.9645998724, 57.7076967993 ],

 

[ 11.9646165315, 57.707666521 ],

 

[ 11.9646513025, 57.7076564113 ],

 

[ 11.9646910265, 57.7076625646 ],

 

[ 11.9646665721, 57.7077068513 ],

 

[ 11.9645998724, 57.7076967993 ]

 

]

 

]

 

},

 

"properties" : {

 

"relations" : "{ \\"Roomnumber: \\" : \\"4023\\", \\"Name:\\" : \\"Jane Doe\\", \\"Title:\\" : \\"Capo di tutti capi\\", \\"Email:\\" : \\"jane.doe@coroleone.org\\" }",

 

"id" : "4023",

 

"level" : "4"

 

}

 

}

 

]

 

}

 

}

 

 

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

13 replies

takashi
Celebrity
  • 7843 replies
  • November 9, 2018

I believe that using the JSONTemplator is the right way. A template expression example could be provided if you could post a sample of feature attributes (set of name/value pairs) and a GeoJSON document that should be created from the attributes.


takashi
Celebrity
  • 7843 replies
  • November 9, 2018

"vpl.txt" you have posted cannot be accessed.


daveatsafe
Safer
Forum|alt.badge.img+19
  • Safer
  • 1637 replies
  • November 9, 2018

Hi @totobobiasos,

The GeoJSON writer may provide what you want. You just need to create the 'level' user attribute on the output feature type, with the type 'json' so you can set a list of values if necessary.


takashi
Celebrity
  • 7843 replies
  • November 9, 2018

Hi @totobobiasos,

The GeoJSON writer may provide what you want. You just need to create the 'level' user attribute on the output feature type, with the type 'json' so you can set a list of values if necessary.

Hi @DaveAtSafe, I'm afraid that the GeoJSON writer won't convert a list attribute to a JSON array. Since the question feature contains a list attribute, I think it would be necessary to convert at least the list attribute to JSON array with the JSONTemplater beforehand, even if you would use the GeoJSON writer to create the destination document.

"These get joined by room number attribute with a Databasejoiner, and because some share rooms, turned into a list attribute."


daveatsafe
Safer
Forum|alt.badge.img+19
  • Safer
  • 1637 replies
  • November 9, 2018

Hi @DaveAtSafe, I'm afraid that the GeoJSON writer won't convert a list attribute to a JSON array. Since the question feature contains a list attribute, I think it would be necessary to convert at least the list attribute to JSON array with the JSONTemplater beforehand, even if you would use the GeoJSON writer to create the destination document.

"These get joined by room number attribute with a Databasejoiner, and because some share rooms, turned into a list attribute."

Hi @takashi,

That's true, although I would have used a ListConcatenator to build the array, then an AttributeCreator to wrap in the square brackets.

I just dislike burying the workspace logic in the JSONTemplater.


totobobiasos
Forum|alt.badge.img
  • Author
  • 17 replies
  • November 12, 2018

Ah. Forgot to translate these files. How good is your swedish? :-)


totobobiasos
Forum|alt.badge.img
  • Author
  • 17 replies
  • November 12, 2018

... and here is an example of the result json that I wish to match:

Don't know where all the backslashes in my file comes from, though.

 

 

 

{

 

"type": "FeatureCollection",

 

"features": [

 

{

 

"type": "Feature",

 

"id": "way/94551277",

 

"properties": {

 

"type": "way",

 

"id": "94551277",

 

"tags": {

 

"buildingpart": "hall",

 

"height": "3.9",

 

"name": "012"

 

},

 

"relations": [

 

{

 

"role": "buildingpart",

 

"rel": "1370728",

 

"reltags": {

 

"height": "4",

 

"level": "0",

 

"name": "Erdgeschoss",

 

"type": "level"

 

}

 

}

 

],

 

"meta": {}

 

},

 

"geometry": {

 

"type": "Polygon",

 

"coordinates": [

 

[

 

[

 

8.6770429,

 

49.4186016

 

],

 

[

 

8.677043,

 

49.418499

 

],

 

[

 

8.6771835,

 

49.418499

 

],

 

[

 

8.6771835,

 

49.4186016

 

],

 

[

 

8.6770429,

 

49.4186016

 

]

 

]

 

]

 

}

 

},

takashi
Celebrity
  • 7843 replies
  • November 12, 2018

This workspace example is not a complete solution (since I cannot understand Swedish!), but might help you to resolve the problem about creating JSON array, I think. The point is to use SUB template expression in the JSONTemplater.

jsontemplater-geojson-writer.fmwt (FME 2018.1.0.3)


totobobiasos
Forum|alt.badge.img
  • Author
  • 17 replies
  • November 12, 2018

This workspace example is not a complete solution (since I cannot understand Swedish!), but might help you to resolve the problem about creating JSON array, I think. The point is to use SUB template expression in the JSONTemplater.

jsontemplater-geojson-writer.fmwt (FME 2018.1.0.3)

Ah! I see what you did there. That helped. A LOT. Now I'm getting closer. Just one (or maybe two?) things.

My resulting geojson says:

 

 

"properties" : {

 

"room_number" : "4021",

 

"relations" : "[ { \\"reltags\\" : {

 

\\"level\\" : \\"4\\",

\\"name\\" : \\"Jane Doe\\",

\\"title\\" : \\"hitman\\",

etc. etc. So far so good.

But, the "relations" should be

"relations" : [

not

"relations" : "[

No matter how I bracket my sub template or root template they become objects, not arrays.

 

 

 


takashi
Celebrity
  • 7843 replies
  • November 12, 2018

This workspace example is not a complete solution (since I cannot understand Swedish!), but might help you to resolve the problem about creating JSON array, I think. The point is to use SUB template expression in the JSONTemplater.

jsontemplater-geojson-writer.fmwt (FME 2018.1.0.3)

Probably you are writing the JSON array as a plain string value into the destination GeoJSON dataset. Make sure that you have set json to the data type for the "relations" column in the User Attributes tab, the GeoJSON writer feature type.


totobobiasos
Forum|alt.badge.img
  • Author
  • 17 replies
  • November 12, 2018

Probably you are writing the JSON array as a plain string value into the destination GeoJSON dataset. Make sure that you have set json to the data type for the "relations" column in the User Attributes tab, the GeoJSON writer feature type.

Words cannot describe my current mood.

 

 

Happiness comes pretty close. Be aware that you have made my day.

Very kind regards from Gothenburg, Sweden


totobobiasos
Forum|alt.badge.img
  • Author
  • 17 replies
  • November 12, 2018

Ok! Pretty much solved.

 

This I can do manually, but still..

 

 

The resulting JSON starts with

 

 

"data" : {

 

"type" : "FeatureCollection",

 

"features" : [

 

 

where "data" is the feature type name. However, in the example data the file starts as:

 

{

 

"type" : "FeatureCollection",

 

"features" : [

 

I know I can remove that by writing and reading the file back, substring remove the top most part and the last bracket. But that's not very neat.

 

Thanks for all the help you all!

 


takashi
Celebrity
  • 7843 replies
  • November 13, 2018

Ok! Pretty much solved.

 

This I can do manually, but still..

 

 

The resulting JSON starts with

 

 

"data" : {

 

"type" : "FeatureCollection",

 

"features" : [

 

 

where "data" is the feature type name. However, in the example data the file starts as:

 

{

 

"type" : "FeatureCollection",

 

"features" : [

 

I know I can remove that by writing and reading the file back, substring remove the top most part and the last bracket. But that's not very neat.

 

Thanks for all the help you all!

 

Make sure that the Fully Conform to the GeoJSON Grammar in the GeoJSON writer is set to 'Yes'.