• bushal

    (@bushal)


    Firstly Martijn, thank you very much for a great plugin, and also the help with my previous problem. I hope you now dont regret it!

    A bit of background; I am an RFS volunteer firefighter in Australia and now that our horrid fire season is over I am trying to get some tools together for the next one.
    A number of us use Oruxmaps as it is very feature rich and we can load up the local topographic maps and work offline. we can also draw or walk round fire extents and store them. With your server it becomes easy to share them with others, and see where the other trucks are.

    Now I would like to do two things.
    1. to draw some of these tracks (always polygons) as an overlay with a fill (ideally in different colours to signify burnt area or active fire etc)
    2. Ideally to import an existing GeoJson published by the RFS which shows the extent of fires in the state (the map is referenced in the Web page link above and the GeoJson is at https://www.rfs.nsw.gov.au/feeds/majorIncidents.json).
    I know this is a big file and we would need to select only the fires that are in our local area, but i noticed that all your tracks are converted into GeoJson, and while I had thought to convert them into KML or GPX i thought i should ask your advice first.

    i am a retired programmer with no mapping experience so i am comfortable extending your work if it is not too complex, but as always we hope that it almost does it already.

    Thanks again for any advice
    Al

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author tinuzz

    (@tinuzz)

    Hi Al,

    I think both things are possible with Trackserver’s external file feature, although I haven’t tried drawing polygons, which would only be possible with KML files at this point.

    If the data you have available is in GeoJSON, it would indeed seem unncessary to convert it to GPX or KML first, only to have Leaflet-Omnivore convert it back to GeoJSON.

    Adding support of GeoJSON files shouldn’t be hard, since I think Leaflet-Omnivore can consume that without problems. It would come down to telling Trackserver about the file type and how to load it.

    I’ll have a look to see how much work it is.

    Regards,
    Martijn.

    Thread Starter bushal

    (@bushal)

    Thanks Martijn, that would be great.

    Plugin Author tinuzz

    (@tinuzz)

    Just a quick answer, because I didn’t have mucht time to look into it.

    It’s not very complicated, but there are one or two caveats to work around.

    First, adding support for ‘geojson’ URLs is easy. Basically, you search the ‘class-trackserver.php’ file for occurrences of ‘kml’, and duplicate that code, replacing all instances of ‘kml’ with ‘geojson’:

    Insert at 1109:
    'geojson' => false,

    Insert at 1278:

    			if ( $atts['geojson'] ) {
    				$urls = explode( ' ', $atts['geojson'] );
    				$j    = 0;
    				foreach ( $urls as $u ) {
    					if ( ! empty( $u ) ) {
    						$u        = $this->proxy_url( $u, $post_id );
    						$tracks[] = array(
    							'track_id'   => 'geojson' . $j,
    							'track_url'  => $u,
    							'track_type' => 'geojson',
    							'style'      => $this->get_style(),
    							'points'     => $this->get_points(),
    							'markers'    => $this->get_markers(),
    							'markersize' => $this->get_markersize(),
    						);
    						$j++;
    					}
    				}
    			}

    For the rest, Trackserver already knows how to display GeoJSON content, because it can use GeoJSON for internal tracks too.

    First caveat: due to its internal use of GeoJSON, Trackserver expects the actual GeoJSON data to be wrapped in some Trackserver-specific construct, so the code must be changed for this use case. The simplest fix would be this:

    In trackserver.js, on line 60, replace

    return o.track;

    with

                if (o.hasOwnProperty( 'track' )) {
                    return o.track;
                }
                else {
                    return o;
                }
    

    With that in place, I was able to display the ‘majorincidents.json’ file using

    [tsmap geojson=<url>]

    It doesn’t seem to work with polygons, though. If your run into CORS restrictions loading JSON from an external domain, you may have to use Trackserver’s proxy feature.

    There may be other issues. Please let me know how well this works.

    Best regards,
    Martijn.

    Thread Starter bushal

    (@bushal)

    Thanks very much for your help. I will fiddle with various options and let you know how I go, as (of course) its the polygons that i am most interested in – they show the fire extent, and i am trying to combine the last known positions of the trucks with where we believe the fire is, along with any new reports of fire extent that the trucks might upload.

    So I have several options, either to convert the GeoJson to KML, which would also allow me to plot the extent on android devices (for example – Locus maps) or to export the location information from TrackServer and plot it on Google maps or similar.

    Back to the drawing board, but there is at least one option that looks like it will work.

    Thanks again for your help

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Overlays and GeoJson’ is closed to new replies.