Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
daturpin
Partner - Creator II
Partner - Creator II

Line layer in Map, why did I end up with this weird format?

Let me start by saying, I, via trial and error, answered my own question. Basically, I have a map in QlikSense Enterprise which shows the positions of ships on the ocean, and the positions of those ships are calculated by interpolation from a table with name, lat, long, and time, where each ship might have 1 or 1000 waypoints, and the calculated position comes from a slider.

Now, it took a lot of trial and error to get this to work in QlikSense, being that QlikSense doesn't natively do macros... Basically I got it to work using Vizlib and the ability of Vizlib to run script and conduct partial app reloads.

And, I thought, since I have that data, wouldn't it also be nice to show a line layer which draws out the paths of the ships over the entire timeline? So I did, but there is weirdness here that I can't quite explain.

So, in the Map, you can create a line layer, and the positional data can be either two fields, or one field with line geometry (or multi-line geometry) using a JSON standard. Sort of. By trial and error, I found this to be a simplified standard, where you format your line geometry as [[lat,lon],[lat,lon],[lat,lon]]. To build this format, I iteratively built the string by concatenating (&) the bits of this during runtime and writing to my table.

Weirdness #1: For some reason, the open square bracket works fine, but to create a close square bracket, I needed to use ']]' for each closed bracket. Why? Dunno, but basically it means the string I need to write is actually:

'[[lat,lon]],[lat,lon]],[lat,lon]]]]'

Weirdness #2: This is also a problem with Google Earth, where if you have a line cross the IDL it instead DRAWS A LINE COMPLETELY AROUND THE OTHER SIDE OF THE EARTH. Which is annoying. But by experimenting, I found that the solution is the same as Google Earth: If your longitude is negative, add 360. So -179 becomes 181, -1 becomes 359, etc. It works. Following are the before and after for a moving vessel:

map broke.jpgmap fixed.jpg

In conclusion, this isn't a question per se, but if anyone can explain why the format of square brackets was so weird, I'd appreciate it. Otherwise I think it's helpful info for anyone making world maps with point and line layers. (fellow wargamers?)

Labels (6)
0 Replies