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

Objects aren't visible after crossing the date boundary (antimeridian) #90

Open
sol1-matt opened this issue Apr 9, 2019 · 10 comments
Open

Comments

@sol1-matt
Copy link

Expected Behavior

When mapping multiple points that are either side of the 180 degree mark all points map is viewing are visible.
eg:
/map?default_zoom=5&default_lat=-7.885147283424331&default_long=179.999 would show points such as Fiji, Vanuatu, Kiribati, Tonga, Samoa or Niue.
/map?default_zoom=5&default_lat=-7.885147283424331&default_long=-179.999 would show points such as Fiji, Vanuatu, Kiribati, Tonga, Samoa or Niue.

Current Behavior

When mapping multiple points that are either side of the 180 degree mark only points on the side the map is viewing are visible.
eg:
/map?default_zoom=5&default_lat=-7.885147283424331&default_long=179.999 would show points such as Fiji, Vanuatu, Kiribati but not Tonga, Samoa or Niue.
/map?default_zoom=5&default_lat=-7.885147283424331&default_long=-179.999 would show the opposite. Points for Tonga, Samoa or Niue are visible but Fiji, Vanuatu, Kiribati disappear

map 179
map -179

Possible Solution

Steps to Reproduce (for bugs)

  1. Add host lat/long values for Tonga, Samoa Niue, Fiji, Vanuatu, Kiribati
  2. View on maps
  3. Switch between default_long=179.999 and default_long=-179.999 when viewing the maps
    You should see 3 locations only that change depending on the side of 180 degrees the view is.

Context

Your Environment

  • Icinga Web 2 Map version (System - About): 1.1.0
  • Icinga Web 2 version and modules (System - About):
    • Icinga Web 2 Version 2.6.2
    • Modules
      • director | 1.6.2
      • map | 1.1.0
      • monitoring | 2.6.2
      • netboximport | 1.0.1
  • Version used (icinga2 --version):
    • icinga2 - The Icinga 2 network monitoring daemon (version: r2.10.3-1)
  • Operating System and version:
    Platform: Ubuntu
    Platform version: 18.04.2 LTS (Bionic Beaver)
  • Enabled features (icinga2 feature list):
    root@icinga:~# icinga2 feature list
    Disabled features: compatlog debuglog elasticsearch gelf graphite influxdb livestatus opentsdb perfdata statusdata syslog
    Enabled features: api checker command ido-mysql mainlog notification
  • Config validation (icinga2 daemon -C):
@davekempe
Copy link

#bigmappeopleproblems

@nbuchwitz
Copy link
Owner

Hi Matt,

that should a bit strange to me. Could you share some demo hosts with coordinates, so I could try to reproduce and fix it?

@sol1-matt
Copy link
Author

Test lat,long
Fiji: -16.432000, 179.365400
Vanuatu: -17.734100, 168.321900
Tonga: -21.136100, -175.203900
Samoa: -13.860600, -171.795200

Another interesting behavior I just noticed
Keeping the zoom negative hides coords that are positive.
Setting the map to /map?default_zoom=9&default_lat=-17.41616680065723&default_long=-182.111 doesn't show Fiji (the lat,long above)

@nbuchwitz nbuchwitz self-assigned this Apr 9, 2019
@nbuchwitz nbuchwitz added the bug label Apr 9, 2019
@nbuchwitz
Copy link
Owner

This is indeed a bug. I will have a look if this is maybe related to the upstream JS map library (leaflet) or is something within my scope I could fix.

@nbuchwitz
Copy link
Owner

The problems is that markers aren't replicated to the "other" worlds (each world has "neighbours" which are treated as independent instances of a map)

For showing all markers in your use case it could help to add 360 to all negative longitudes, but doesn't resolve the missing markers in the "neighbour" worlds

See Leaflet/Leaflet#1945 and https://stackoverflow.com/questions/38820724/how-to-display-leaflet-markers-near-the-180-meridian

@nbuchwitz
Copy link
Owner

Leaflet/Leaflet#6172

@nbuchwitz
Copy link
Owner

A quick fix for the time we haven't found a better solution is ihmo to add 360 to your negative longitudes (only for the hosts nearby australia - not in central europe)

@nbuchwitz nbuchwitz changed the title Unable to display multiple points either side of 180 degrees at the same time Objects aren't visible after crossing the date boundary (antimeridian) Apr 9, 2019
@davekempe
Copy link

Thanks for the fast response @nbuchwitz. We will give that a try.

@sol1-matt
Copy link
Author

The quick fix doesn't work if the view is a negative longitude as well.

I changed this code in public/js/module.js to try and modify the longitudes on the fly which does work when the map initially loads regardless of which side of the antimeridian the longitudes lay on but moving the map to the other side of the antimeridian causes all points to disappear.

        function processData(json) {
            if (json['message']) {
                errorMessage(json['message']);
                return;
            }
            removeOldMarkers(id, json);

            var dataurl = new URL(window.location);
            var viewlong = dataurl.searchParams.get('default_long');

            $.each(json, function (type, element) {
                $.each(element, function (identifier, data) {
                    if (data.length < 1 || data['coordinates'] == "") {
                        console.log('found empty coordinates: ' + data)
                        return true
                    } else {
                        if (viewlong != null) {
                            if (parseFloat(viewlong) > parseFloat(0)) {
                                if (data['coordinates'][1] < 0 && data['coordinates'][1] > -180) {
                                    data['coordinates'][1] = parseFloat(data['coordinates'][1]) + 360;
                                }
                            } else {
                                if (data['coordinates'][1] > 0 && data['coordinates'][1] < 180) {
                                    data['coordinates'][1] = parseFloat(data['coordinates'][1]) - 360;
                                }
                            }
                        }
                    }

If I console log the date['coordinates'] I can see them changes as the view is moved back and forth without a page reload so it is likely related to the initial problem, something like the zone not changing even though the view default_long does.

There may be a better longitude value to use than the url default_long, just need to find it.

@sol1-matt
Copy link
Author

no, that isn't it either map_default_long doesn't change when the map is scrolled but matching the longitude to this value doesn't draw them when the view url switches between negative and positive.

Leaflet.RepeatedMarkers plugin is another option
https://gitlab.com/IvanSanchez/Leaflet.RepeatedMarkers

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

No branches or pull requests

3 participants