Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multi-line from query #586

Closed
prb11199 opened this issue Nov 2, 2019 · 13 comments
Closed

multi-line from query #586

prb11199 opened this issue Nov 2, 2019 · 13 comments
Labels

Comments

@prb11199
Copy link

prb11199 commented Nov 2, 2019

Setup

  • Maps version:
  • MW version:
  • PHP version:
  • SMW version (if applicable):

Issue

Hi,
Thanks for reading my question.
I would like to know how I can generate a make using a query, with multiple markers and lines.
markers and lines would come from pages representing power stations/power lines.
Each page could have 1 or more power station.
Each page could have 1 or more line segments.

I had a try, but I can't seem to get it to work.
I tried to copy some of this, but it didn't work for me (I couldn't get lines to show up with a query, only markers): https://www.transit.wiki/San_Francisco_Bay_Ferry

I also tried looking through the semantic wiki page, but couldn't find a much there.

Thanks in advance for your help

@JeroenDeDauw
Copy link
Member

It is not possible to query lines onto a map. You can however add lines to a map that was points queried onto it, which I assume is what is Transit Wiki is doing.

See https://www.semantic-mediawiki.org/wiki/Extension:Maps/Displaying_maps#Lines and https://www.semantic-mediawiki.org/wiki/Extension:Maps/GeoJSON

Both the lines parameter and the geojson parameter work in #ask queries.

Querying lines and other shapes is tracked by #239

@prb11199
Copy link
Author

prb11199 commented Nov 5, 2019

Dear JeroenDeDauw,

Thank you for your reply.
On the maps I will always have a marker first, so I can query by that, so I think that should be okay.
I am storing a list of points, separated by colons, in each page as a properties called "Has Route".
I would like to be able to query within the first marker query to then plot these lines.

I can get the marker query and line query to return the results I want separately, but not together.
In the example attached below, The first #ask (Dummy1) returns the correct results. For example,
51.916903, -2.059997: 49.625418, 1.015549

If I copy this and paste it into Dummy2 query, e.g.
|lines=51.916903, -2.059997: 49.625418, 1.015549 then the map displayed as I want.
However, if i use the #ask within Dummy 2 i.e.
|lines= {{#ask: ... then it doesnt plot any lines, only the markers.

== Dummy1 ==
{{#ask: 
            [[Has voltage:: 400 kV]][[Has Route::+]]
            |? Has Route =
            |mainlabel=- 
            |format=list
	    |sep=;  
}}
== Dummy2 ==

<div class=bigmap>
{{#ask:
  [[Category: Hvdc system]]
  [[Has Route::+]]
  |?Has location =
  |width=600
  |height=450
  |lines=  {{#ask: 
            [[Has voltage:: 400 kV]][[Has Route::+]]
            |? Has Route =
            |mainlabel=- 
            |format=list
	    |sep=;
            }}
}}

</div>

Properties:

Has Route. type: text. co-ordinates, separated by colons.

Can anyone see where I'm going wrong?
Thanks for your help in advance.

@JeroenDeDauw
Copy link
Member

I suspect the inner ask query is not parsed before it is given to the Maps extension. Once Maps gets the value for lines it will just try to interpret as a set of lines. It will not invoke the wikitext parser. Again I'm not sure about the first bit as I have not used much wikitext as of late. Would be good if someone can confirm.

@JeroenDeDauw
Copy link
Member

I just tried putting wikitext into the lines parameter and it seems to be working fine (not what I expected). Demo: https://sandbox.semantic-mediawiki.org/wiki/Utilisateur:Jeroen_De_Dauw/LinesParse

So my first guess would be that your query is not creating valid input for the lines parameter. Though that can't be the issue if it works after copy and pasting. You could try asking on the MediaWiki mailing list. https://www.mediawiki.org/wiki/Mailing_lists

@prb11199
Copy link
Author

Thanks for your sample.

In case it was the inner as #ask not being evaluated, I tried another approach.

I made a new template). The idea being that the marker location and line(route) queries are evaluated before being passed to the template, where the map is constructed.

Template:Location
I include 'the route is' and 'the site location is' as a check to see if the information is passed through into the template. It is: this displays on the main page.

{{#display_map:
  {{{site_location|}}}
  |width=600
  |height=300
  |zoom = {{{zoom}}}
  |lines = {{{routes}}}
}}
*The route is:  {{{routes|}}}
*The site location is:  {{{site_location|}}}

Main page
For simplicity, there is only one page that 'Has Route' at the moment, so only a single result is returned.

{{Location
 |site_location = {{#ask: [[Has Route::+]] | ?Has Route |Format = list |headers=hide   |mainlabel=-}}
 |zoom = 5
 |routes = {{#ask: [[Has Route::+]] | ?Has Route  |Format = list   |headers=hide   |mainlabel=-}}
}}

I can't seem to understand why the results are passed through to the template okay ('the route is' and 'the site location is' are displayed), but it is not displaying in the map.

Any advice is welcome.

Kind regards.

@JeroenDeDauw
Copy link
Member

It'd be helpful for me to know what the Maps extension is receiving as parameter value. Can you add the following line to your copy of Maps and give me the output you get when you save the page with the not-working dispay_map call? 145ffb2

Here is a screenshot of what I get when embedding lines from another page, as in the SMW sandbox example I linked before:

image

My guess is that either for some reason Maps is getting something not fully parsed or that there is some added crap (like a HTML div tag) in the parsed result.

@prb11199
Copy link
Author

Thanks for your reply.
I made an example in the sandbox, so you can see the exact set-up.

https://sandbox.semantic-mediawiki.org/wiki/Utilisateur:Fred/projectmap
https://sandbox.semantic-mediawiki.org/wiki/Utilisateur:Fred/projectexample

The page "project example" has three locations: London, Madrid and Antwerp; stored in Has coordinates.
It also has a single route, which includes all three locations, separated by a colon.
Has route is a text property.

In the project map page, I tried using #display_map, as in your example, to display the lines.
As you can see, in the second map image, only the second Has Route location is shown (Madrid).

I also tried it on my own wiki (sorry, it's not publicly available), and changed the code as you requested.
Below is the output it generated.
The format seems to be slightly different from yours, although roughly similar? It seems it has a first argument [0] of length zero; could this be an issue? I suppose this is the marker argument?

array(4) { [0]=> string(0) "" [1]=> string(225) "lines= 51.465370, -0.156426 : 40.421154, -3.703832 : 51.206582, 4.325629 " [2]=> string(12) "width=600 " [3]=> string(11) "height=400 " }```

@JeroenDeDauw
Copy link
Member

I now replicated the whole thing on my dev machine and this is the parameter maps is getting:

lines = <span class="smw-format list-format "><span class="smw-row"><span class="smw-field"><span class="smw-value">51.465370, -0.156426 : 40.421154, -3.703832 : 51.206582, 4.325629</span></span></span></span>

The output you posted is presumably from a page where the first display_map call has the lines parameter with a fixed value and not with a query.

Either way, the issue is what I suspected it was: Maps is getting a bunch of HTML tags from the ask query. I'm a bit fuzzy on what exactly the SMW syntax is to really only get the value itself. Ping @kghbln.

@kghbln
Copy link
Member

kghbln commented Nov 19, 2019

You mean something like this change from "list" to "plainlist" whereas "plainlist" inherited the behaviour from the former "list" printer starting with SMW 3.0?

@prb11199
Copy link
Author

That's interesting; and would make sense, I guess.
I also checked again on my own machine, and I am getting a result of:

array(4) { [0]=> string(0) "" [1]=> string(211) "lines= 51.465370, -0.156426 : 40.421154, -3.703832 : 51.206582, 4.325629 " [2]=> string(12) "width=600 " [3]=> string(11) "height=400 " }

for a wikitext of. As you can see, it has query for lines, so i'm unsure of the difference.

{{#display_map:
  |lines= {{#ask: 
          [[Has route::+]]
          |?Has route =
          |mainlabel=- 
          |format=list
	  |sep=;
      }}
  |width=600
  |height=400
}}

Do you know of any examples where people have plotted lines from queries before?
The example I posted previously seemed to have something similar, but it just doesn't work for me.
https://www.transit.wiki/San_Francisco_Bay_Ferry

@prb11199
Copy link
Author

ereas "plainlist" inherited the behaviour form the former "list" printer starting with SMW 3.0?

I just tried it on my own machine and it works fantastically!
thank you so much

@JeroenDeDauw
Copy link
Member

It is now possible to show some love via mini-donation https://github.com/sponsors/JeroenDeDauw ;)

@kghbln
Copy link
Member

kghbln commented Nov 20, 2019

I just tried it on my own machine and it works fantastically!

Great, I guess it was good that I was able to help. :)

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

No branches or pull requests

3 participants