Skip to content
This repository has been archived by the owner on Mar 29, 2019. It is now read-only.

Handling Lines in SemanticMaps #13

Closed
Wilkins opened this issue May 13, 2014 · 13 comments
Closed

Handling Lines in SemanticMaps #13

Wilkins opened this issue May 13, 2014 · 13 comments

Comments

@Wilkins
Copy link

Wilkins commented May 13, 2014

Hi,

I'm currently using SemanticMaps to display points on an Openlayers map, which works like a charm.
I use internal objets to create Name/Coords items to display on my map.

Now I would like to display multi points lines on a map using SemanticMaps. I know it is not implemented yet, but I have development skills, and I would be glad to help.

I made a basic proof of concept with that kind of JSON data on a wiki page :

"locations":[
{"text":"Bordeaux","title":"Bordeaux","link":null,"lat":44.84182,"lon":-0.568892,"alt":0,"address":"","icon":"","group":"","inlineLabel":"","visitedicon":""},
{"text":"Toto","title":"Toto","link":null,"lat":44.84182,"lon":-0.468892,"alt":0,"address":"","icon":"","group":"","inlineLabel":"","visitedicon":""},
{"text":"Camblanes","title":"Camblanes","link":null,"lat":44.765658,"lon":-0.485895,"alt":0,"address":"","icon":"","group":"","inlineLabel":"","visitedicon":""}
],
"lines":[
{"text":"","title":"","link":null,"strokeColor":"#FF0000","strokeOpacity":"1","strokeWeight":"2","pos":[{"lat":59.9699756,"lon":5.7331073},{"lat":60.3912628,"lon":5.3220544},{"lat":60.3872241,"lon":6.343943}]},
{"text":"","title":"","link":null,"strokeColor":"#FF0000","strokeOpacity":"1","strokeWeight":"2","pos":[{"lat":56.3912628,"lon":5.3220544},{"lat":55.3872241,"lon":6.343943}]},
{"text":"","title":"","link":null,"strokeColor":"#FF0000","strokeOpacity":"1","strokeWeight":"2","pos":[{"lat":59.3912628,"lon":5.3220544},{"lat":60.3872241,"lon":6.343943}]}
]

And it worked. It nicely displayed the lines and the points on the map (although it was not centered correctly).

So now I'm trying to make SemanticMaps query the lines data to display it in the JSON.

I tried to look into it already, but the first problem I encountered was that the Semantic Type « Geographic coordinate » doesn't handle the value « 59.9699756,5.7331073:60.3912628,5.3220544:60.3872241,6.343943 » because it is not considered valid. Which is quite normal.

Now my question is : How should I handle this ?

  • Should I hack the parser to make this value valid ? But I think that I would have to touch the Maps extension.
  • Should I change the format of line coordinates ?

Have you already thought about how it could be handled ?

Any information or tips about this would be a great help.

Thanks.

@acnetj
Copy link

acnetj commented Jan 19, 2015

I handle lines by using the code for lines parameter in the Maps extension. The line code is stored as a text property in the semantic wiki and use another ask query to display the line: http://www.transitunlimited.org/San_Francisco_Bay_Ferry

The advantage of this method is that I can use the code directly created from the map editor.

This method works with Maps/SM version 2.X, but no longer works in version 3.X.

@Wilkins
Copy link
Author

Wilkins commented Mar 28, 2015

Hi,

@acnetj, thank you for this tip ! I use that technique too now, it works great.

Have a nice day

PS: @JeroenDeDauw It's ok for me with this workaround, I don't know if you want to keep this issue/enhancement open or if you would rather close it. Thanks.

@JeroenDeDauw
Copy link
Member

It's useful to keep this open to track implementing real support. And as @acnetj mentioned, this no longer works in 3.x.

@acnetj do you know why it no longer works?

@acnetj
Copy link

acnetj commented Apr 1, 2015

I have been occupied with other things lately so I haven't have time to take a look. What I know is that for some reason the lines parameters are no longer included in the ask query like the last version.

Andy


On Mon, 3/30/15, Jeroen De Dauw notifications@github.com wrote:

Subject: Re: [SemanticMaps] Handling Lines in SemanticMaps (#13)
To: "SemanticMediaWiki/SemanticMaps" SemanticMaps@noreply.github.com
Cc: "acnetj" andychow@pobox.com
Date: Monday, March 30, 2015, 10:17 PM

It's useful to keep this open
to track implementing real support. And as @acnetj mentioned,
this no longer works in 3.x.

@acnetj do you know
why it no longer works?


Reply to this email directly or view
it on GitHub.

@kriegfrj
Copy link

kriegfrj commented Dec 3, 2015

Hi all,

I'm new to SMW and I have a need for this sort of functionality. I'm at the very early stages of trying to develop it myself.

Found this url which i thought might be relevant:

http://geospatialelucubrations.blogspot.com.au/2013/10/semantic-mediawiki-promising-platform.html?m=1

@Wilkins
Copy link
Author

Wilkins commented Dec 3, 2015

Hi,

This is the workaround I use, to include lines in Maps using SMW Data.

I installed the Semantic Internal Objects extension

In pages I want a route, I insert this : (Rouen and Paris are 2 cities in France)

{{Route|Rouen-Paris|49.440482,1.093772:47,2}}

Where I want my map, I insert a simple map from the Maps extensions (not Semantic Maps)

{{#display_map: <!-- here you can add points if you want -->
|mainlabel=-
|lines=
{{#ask:  [[Route::+]] |?Mapdata= |mainlabel=- |format=list |sep=; |limit=200}}
|center=Paris
|zoom=3
|height=700
|service=leaflet
}}

Here, my is my Template:Route using the Semantic Internal Objects

<includeonly>{{#set_internal:Route
|Name={{{1}}}
|Data={{{2}}}
|Mapdata={{{2}}}~{{{1}}}~ ~#156BB4
}}</includeonly><noinclude>
All the routes are Blue like #156BB4
== Usage ==
<pre>
{{Route|Rouen-Paris|49.440482,1.093772:47,2}}
</pre>
== Rendering ==

{{Route|Rouen-Paris|49.440482,1.093772:47,2}}

</noinclude>

To add the coordinates of your Route, I suggest you use the OSRM - Open Source Routing Machine.
Once you create you track, you can export it as GPX.

With your GPX, you use the GPX Simplify Optimizer which is a great tool created by @stefanocudini. It will allow you to simplify the GPX tracks so there is less points, and export it in Mediawiki format like A,B:C,D:E,F etc...
It works perfectly in Semantics Mediawiki with hundreds of points. (I didn't test it with more yet)

Hope this can help.

@krabina
Copy link
Contributor

krabina commented Dec 3, 2015

this is great, can you mabe publish this as tip?

http://semantic-mediawiki.org/wiki/Category:Tips

cheers,
Bernhard

----- Am 3. Dez 2015 um 10:53 schrieb Thibault Taillandier notifications@github.com:

Hi,

This is the workaround I use, to include lines in Maps using SMW Data.

I installed the Semantic Internal Objects extension

In pages I want a route, I insert this : (Rouen and Paris are 2 cities in
France)
{{Route|Rouen-Paris|49.440482,1.093772:47,2}}

Where I want my Map
{{#display_map:
|mainlabel=-
|lines=
{{#ask: [[Route::+]] |?Mapdata= |mainlabel=- |format=list |sep=; |limit=200}}
|center=Paris
|zoom=3
|height=700
|service=leaflet
}}

Here, my is my Template:Route using the Semantic Internal Objects
{{#set_internal:Route
|Name={{{1}}}
|Data={{{2}}}
|Mapdata={{{2}}}{{{1}}} ~#156BB4
}}
All the routes are Blue like #156BB4
== Usage ==

{{Route|Rouen-Paris|49.440482,1.093772:47,2}}

== Rendering ==

{{Route|Rouen-Paris|49.440482,1.093772:47,2}}

To know the coordinates of your Route, I suggest you use the OSRM - Open Source
Routing Machine .
Once you create you track, you can export it as GPX.

With your GPX, you use the GPX Simplify Optimizer which is a great tool created
by @stefanocudini . It will allow you to simplify the GPX tracks, and export it
in Mediawiki format like A,B:C,D:E,F etc...
It works perfectly in Semantics Mediawiki with hundreds of points. (I didn't
test it with more yet)

Hope this can help.


Reply to this email directly or view it on GitHub .

@Wilkins
Copy link
Author

Wilkins commented Dec 3, 2015

@kriegfrj
Copy link

kriegfrj commented Dec 3, 2015

Thanks for this, it does help. However, if I have understood you correctly your solution is more to do with displaying polylines. I am also interested in doing spatial queries beyond the simple "radius" queries that are currently supported. For example, I'd like to be able to define a polyline, and then do an #ask query to find all addresses in that region. I would also like to be able to import geometry from other GIS formats. These are the shorts of things listed in the road map I linked to. If this is already possible with Semantic Maps I'd appreciate a pointer in the right direction.

@Wilkins
Copy link
Author

Wilkins commented Dec 3, 2015

I understand your problem @kriegfrj , although I'm not sure it is possible yet.

Because many GIS applications are based on PostGIS (extension of Postgres), like OpenStreetMaps itself.
But Mediawiki is based on Mysql only. Mysql only support Spatial data since Mysql 5.7 which is not widely spread yet.

The #ask query you want to do would require the database to do the calculation for more efficiency. Doing that in the Semantic Maps extension itself looks like reinventing the wheel in a higher level language, which might be quite bad performance wise.

I'm not a Semantic Maps developer, so I might be wrong, I guess some people involved in the project could answer that problem more precisely.

@kriegfrj
Copy link

kriegfrj commented Dec 3, 2015

Thanks for the comments, @Wilkins.

Actually, MySQL has supported spatial data since 5.0, but spatial indexes were not supported in InnoDB tables until 5.7 (they've been in MyISAM tables since at least 5.0). You can still do spatial queries without the indexes but they are slower. Anyway I have my own server so of our means i have to install 5.7 that's not a problem.

I think you are right that the best implementation would defer the spatial operations to the db which would save having top reinvent the wheel and probably give better preformance anyway. That is essentially the solution mapped out in the road map I linked to above.

Your response is helpful - simply knowing that it hasn't been done yet gives me confidence to try without worrying that I am duplicating effort.

@JeroenDeDauw
Copy link
Member

Subscribers of this might also want to track #17

@JeroenDeDauw
Copy link
Member

Now tracked at ProfessionalWiki/Maps#239

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants