Search in sources :

Example 1 with Location

use of de.fhpotsdam.unfolding.geo.Location in project constellation by constellation-app.

the class MapViewTileRenderer method handleMouseZoom.

/**
 * Update the zoom level of the map based on the given set of markers.
 *
 * @param event the mouse event which caused the zoom
 * @param markers the markers to zoom to
 */
private void handleMouseZoom(final Set<ConstellationAbstractMarker> markers) {
    assert !SwingUtilities.isEventDispatchThread();
    if (markers == null) {
        return;
    }
    // the zoomAndPanToFit method is known to break for any of the following locations
    final List<Location> breakingLocations = new ArrayList<>();
    breakingLocations.add(new Location(Float.POSITIVE_INFINITY, Float.POSITIVE_INFINITY));
    breakingLocations.add(new Location(Float.POSITIVE_INFINITY, Float.NEGATIVE_INFINITY));
    breakingLocations.add(new Location(Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY));
    breakingLocations.add(new Location(Float.NEGATIVE_INFINITY, Float.NEGATIVE_INFINITY));
    final List<Location> locations = markers.stream().map(marker -> marker.getLocation()).filter(location -> !breakingLocations.contains(location)).collect(Collectors.toList());
    if (!locations.isEmpty()) {
        map.zoomAndPanToFit(locations);
    }
}
Also used : MarkerUtilities(au.gov.asd.tac.constellation.views.mapview.utilities.MarkerUtilities) NewtCanvasAWT(com.jogamp.newt.awt.NewtCanvasAWT) URL(java.net.URL) MapProvider(au.gov.asd.tac.constellation.views.mapview.providers.MapProvider) StringUtils(org.apache.commons.lang3.StringUtils) Map(java.util.Map) MouseEvent(processing.event.MouseEvent) KeyEvent(processing.event.KeyEvent) Lookup(org.openide.util.Lookup) Collection(java.util.Collection) PApplet(processing.core.PApplet) Set(java.util.Set) ConstellationAbstractMarker(au.gov.asd.tac.constellation.views.mapview.markers.ConstellationAbstractMarker) Logger(java.util.logging.Logger) Component(java.awt.Component) Collectors(java.util.stream.Collectors) PSurface(processing.core.PSurface) PConstants(processing.core.PConstants) List(java.util.List) ConstellationInstalledFileLocator(au.gov.asd.tac.constellation.utilities.file.ConstellationInstalledFileLocator) PanMapEvent(de.fhpotsdam.unfolding.events.PanMapEvent) Location(de.fhpotsdam.unfolding.geo.Location) ConstellationAbstractFeature(au.gov.asd.tac.constellation.views.mapview.features.ConstellationAbstractFeature) ThreadUtils(org.apache.commons.lang3.ThreadUtils) UnfoldingMap(de.fhpotsdam.unfolding.UnfoldingMap) EventDispatcher(de.fhpotsdam.unfolding.events.EventDispatcher) BarScaleUI(de.fhpotsdam.unfolding.ui.BarScaleUI) MapOverlay(au.gov.asd.tac.constellation.views.mapview.overlays.MapOverlay) ConstellationClusterMarker(au.gov.asd.tac.constellation.views.mapview.markers.ConstellationClusterMarker) HashMap(java.util.HashMap) ConstellationMarkerFactory(au.gov.asd.tac.constellation.views.mapview.markers.ConstellationMarkerFactory) ArrayList(java.util.ArrayList) Level(java.util.logging.Level) Graph(au.gov.asd.tac.constellation.graph.Graph) MarkerCache(au.gov.asd.tac.constellation.views.mapview.utilities.MarkerCache) HashSet(java.util.HashSet) SwingUtilities(javax.swing.SwingUtilities) Applet(java.applet.Applet) MarkerState(au.gov.asd.tac.constellation.views.mapview.utilities.MarkerState) GLWindow(com.jogamp.newt.opengl.GLWindow) ConstellationPointFeature(au.gov.asd.tac.constellation.views.mapview.features.ConstellationPointFeature) SharedDrawable(au.gov.asd.tac.constellation.visual.opengl.utilities.SharedDrawable) MapLayer(au.gov.asd.tac.constellation.views.mapview.layers.MapLayer) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) GraphElement(au.gov.asd.tac.constellation.views.mapview.utilities.GraphElement) Field(java.lang.reflect.Field) File(java.io.File) MapUtils(de.fhpotsdam.unfolding.utils.MapUtils) ZoomMapEvent(de.fhpotsdam.unfolding.events.ZoomMapEvent) ArrayList(java.util.ArrayList) Location(de.fhpotsdam.unfolding.geo.Location)

Example 2 with Location

use of de.fhpotsdam.unfolding.geo.Location in project constellation by constellation-app.

the class MapViewTileRenderer method mousePressed.

@Override
public void mousePressed(final MouseEvent event) {
    assert !SwingUtilities.isEventDispatchThread();
    if (event.getButton() == PConstants.CENTER || event.getButton() == PConstants.LEFT) {
        // zoom to box
        boxOriginX = event.getX();
        boxOriginY = event.getY();
    } else if (event.getButton() == PConstants.RIGHT && event.getCount() == 2) {
        dispatcher.register(map, ZoomMapEvent.TYPE_ZOOM, map.getId());
        // Pan + Zoom (order is important)
        final PanMapEvent panMapEvent = new PanMapEvent(this, map.getId());
        final Location location = map.getLocation(mouseX, mouseY);
        panMapEvent.setToLocation(location);
        dispatcher.fireMapEvent(panMapEvent);
        final ZoomMapEvent zoomMapEvent = new ZoomMapEvent(this, map.getId(), ZoomMapEvent.ZOOM_BY_LEVEL, 1);
        zoomMapEvent.setTransformationCenterLocation(location);
        dispatcher.fireMapEvent(zoomMapEvent);
        dispatcher.unregister(map, ZoomMapEvent.TYPE_ZOOM, map.getId());
    } else {
    // Do nothing
    }
    overlays.forEach(overlay -> overlay.mousePressed(event));
}
Also used : ZoomMapEvent(de.fhpotsdam.unfolding.events.ZoomMapEvent) PanMapEvent(de.fhpotsdam.unfolding.events.PanMapEvent) Location(de.fhpotsdam.unfolding.geo.Location)

Example 3 with Location

use of de.fhpotsdam.unfolding.geo.Location in project constellation by constellation-app.

the class MapViewTopComponent method zoomLocationBasedOnGeoType.

private void zoomLocationBasedOnGeoType(final String geoType, final String location) throws AssertionError {
    final ConstellationAbstractMarker marker;
    switch(geoType) {
        case GEO_TYPE_COORDINATE:
            final String[] coordinate = location.split("[,\\s]+");
            if (coordinate.length != 2 && coordinate.length != 3) {
                NotifyDisplayer.display("Invalid coordinate syntax provided, should be comma or space separated", NotifyDescriptor.ERROR_MESSAGE);
                return;
            }
            final float latitude;
            final float longitude;
            final float radius;
            try {
                latitude = Float.parseFloat(coordinate[0]);
                longitude = Float.parseFloat(coordinate[1]);
                if (coordinate.length == 3) {
                    radius = Float.parseFloat(coordinate[2]);
                } else {
                    radius = 0;
                }
            } catch (final NumberFormatException ex) {
                NotifyDisplayer.display("Invalid coordinate data provided, latitude and longitude should be numbers", NotifyDescriptor.ERROR_MESSAGE);
                return;
            }
            if (latitude <= -90F || latitude >= 90F) {
                NotifyDisplayer.display("Invalid coordinate data provided, latitude should be in the range [-90. 90]", NotifyDescriptor.ERROR_MESSAGE);
                return;
            }
            if (longitude <= -180F || longitude >= 180F) {
                NotifyDisplayer.display("Invalid coordinate data provided, longitude should be in the range [-180, 180]", NotifyDescriptor.ERROR_MESSAGE);
                return;
            }
            if (radius < 0F) {
                NotifyDisplayer.display("Invalid coordinate data provided, radius should be greater than or equal to 0", NotifyDescriptor.ERROR_MESSAGE);
                return;
            }
            final Location coordinateLocation = new Location(latitude, longitude);
            if (radius > 0) {
                final float radiusDD = (float) Distance.Haversine.kilometersToDecimalDegrees(radius);
                final Location coordinateDelta = new Location(coordinateLocation.x + radiusDD, coordinateLocation.y + radiusDD);
                final List<Location> circleVertices = MarkerUtilities.generateCircle(coordinateLocation, coordinateDelta);
                final ConstellationShapeFeature coordinateFeature = new ConstellationShapeFeature(ConstellationFeatureType.POLYGON);
                circleVertices.forEach(vertex -> coordinateFeature.addLocation(vertex));
                marker = renderer.addCustomMarker(coordinateFeature);
            } else {
                final ConstellationPointFeature coordinateFeature = new ConstellationPointFeature(coordinateLocation);
                marker = renderer.addCustomMarker(coordinateFeature);
            }
            break;
        case GEO_TYPE_GEOHASH:
            final double[] geohashCoordinates = Geohash.decode(location, Geohash.Base.B16);
            final ConstellationShapeFeature geohashFeature = new ConstellationShapeFeature(ConstellationFeatureType.POLYGON);
            geohashFeature.addLocation(new Location(geohashCoordinates[0] - geohashCoordinates[2], geohashCoordinates[1] - geohashCoordinates[3]));
            geohashFeature.addLocation(new Location(geohashCoordinates[0] + geohashCoordinates[2], geohashCoordinates[1] - geohashCoordinates[3]));
            geohashFeature.addLocation(new Location(geohashCoordinates[0] + geohashCoordinates[2], geohashCoordinates[1] + geohashCoordinates[3]));
            geohashFeature.addLocation(new Location(geohashCoordinates[0] - geohashCoordinates[2], geohashCoordinates[1] + geohashCoordinates[3]));
            geohashFeature.addLocation(new Location(geohashCoordinates[0] - geohashCoordinates[2], geohashCoordinates[1] - geohashCoordinates[3]));
            marker = renderer.addCustomMarker(geohashFeature);
            break;
        case GEO_TYPE_MGRS:
            final double[] mgrsCoordinates = Mgrs.decode(location);
            final Location mgrsLocation = new Location(mgrsCoordinates[0], mgrsCoordinates[1]);
            final ConstellationPointFeature mgrsFeature = new ConstellationPointFeature(mgrsLocation);
            marker = renderer.addCustomMarker(mgrsFeature);
            break;
        default:
            marker = null;
            break;
    }
    renderer.zoomToLocation(marker == null ? null : marker.getLocation());
}
Also used : ConstellationAbstractMarker(au.gov.asd.tac.constellation.views.mapview.markers.ConstellationAbstractMarker) ConstellationShapeFeature(au.gov.asd.tac.constellation.views.mapview.features.ConstellationShapeFeature) ConstellationPointFeature(au.gov.asd.tac.constellation.views.mapview.features.ConstellationPointFeature) Location(de.fhpotsdam.unfolding.geo.Location)

Example 4 with Location

use of de.fhpotsdam.unfolding.geo.Location in project constellation by constellation-app.

the class AbstractPathsLayer method update.

@Override
public PImage update() {
    if (graph == null) {
        return null;
    }
    final Set<Marker> onScreenMarkers;
    final List<Tuple<GraphElement, GraphElement>> paths = new ArrayList<>();
    try (final ReadableGraph readableGraph = graph.getReadableGraph()) {
        // update on screen markers, collecting the ids of the vertices involved in valid paths along the way
        final ScreenPosition topLeft = map.getScreenPosition(map.getTopLeftBorder());
        final ScreenPosition bottomRight = map.getScreenPosition(map.getBottomRightBorder());
        onScreenMarkers = renderer.getMarkerCache().keys().stream().filter(marker -> {
            final ScreenPosition markerPosition = map.getScreenPosition(marker.getLocation());
            final boolean onScreen = markerPosition != null && markerPosition.x > topLeft.x && markerPosition.y > topLeft.y && markerPosition.x < bottomRight.x && markerPosition.y < bottomRight.y;
            if (drawPathsToOffscreenMarkers() || onScreen) {
                final Set<GraphElement> elementsAtMarker = renderer.getMarkerCache().get(marker);
                if (elementsAtMarker != null) {
                    elementsAtMarker.forEach(element -> paths.addAll(getPathsForElement(readableGraph, element)));
                }
            }
            return onScreen;
        }).collect(Collectors.toSet());
        onScreenMarkerCount = onScreenMarkers.size();
    }
    if (onScreenMarkers.isEmpty()) {
        return null;
    }
    final Map<GraphElement, Marker> elementToMarkerCache = new HashMap<>();
    renderer.getMarkerCache().keys().forEach(marker -> renderer.getMarkerCache().get(marker).forEach(element -> elementToMarkerCache.put(element, marker)));
    // set up a color palette
    final int[] palette = Arrays.asList(ConstellationColor.createLinearPalette(N_COLORS, SRC_COLOR, DST_COLOR)).stream().mapToInt(c -> MarkerUtilities.color(c)).toArray();
    final int width = renderer.width - 5;
    final int height = renderer.height - 5;
    final PGraphics pathsImage = renderer.createGraphics(width, height, PConstants.JAVA2D);
    pathsImage.beginDraw();
    // deduplicate paths, storing duplicate counts
    int maxWeight = 1;
    final Map<Tuple<GraphElement, GraphElement>, Integer> dedupedPaths = new HashMap<>();
    for (final Tuple<GraphElement, GraphElement> path : paths) {
        if (dedupedPaths.containsKey(path)) {
            final int weight = dedupedPaths.get(path) + 1;
            if (weight > maxWeight) {
                maxWeight = weight;
            }
            dedupedPaths.put(path, weight);
        } else {
            dedupedPaths.put(path, 1);
        }
    }
    // draw weighted paths
    final int maxWeightFinal = maxWeight;
    dedupedPaths.forEach((path, weight) -> {
        final Marker sourceMarker = elementToMarkerCache.get(path.getFirst());
        final Marker destinationMarker = elementToMarkerCache.get(path.getSecond());
        final boolean validPath = (drawPathsToOffscreenMarkers() && (onScreenMarkers.contains(sourceMarker) || onScreenMarkers.contains(destinationMarker))) || (onScreenMarkers.contains(sourceMarker) && onScreenMarkers.contains(destinationMarker));
        if (validPath) {
            final Location sourceLocation = sourceMarker != null ? sourceMarker.getLocation() : null;
            final Location destinationLocation = destinationMarker != null ? destinationMarker.getLocation() : null;
            if (sourceLocation != null && destinationLocation != null) {
                final ScreenPosition sourcePosition = map.getScreenPosition(sourceLocation);
                final ScreenPosition destinationPosition = map.getScreenPosition(destinationLocation);
                final float lineWidth = Math.max(maxWeightFinal > MAX_LINE_WIDTH ? (MAX_LINE_WIDTH * (weight / (float) maxWeightFinal)) + 1 : weight + 1, 2);
                pathsImage.strokeWeight(lineWidth);
                pathsImage.pushMatrix();
                pathsImage.translate(sourcePosition.x, sourcePosition.y);
                pathsImage.rotate(PApplet.atan2((destinationPosition.y - sourcePosition.y), (destinationPosition.x - sourcePosition.x)));
                final float translatedDestiniationPosition = (float) Math.hypot(destinationPosition.x - sourcePosition.x, destinationPosition.y - sourcePosition.y);
                drawColoredLine(pathsImage, translatedDestiniationPosition, lineWidth, palette);
                pathsImage.popMatrix();
            }
        }
    });
    pathsImage.endDraw();
    return pathsImage;
}
Also used : Arrays(java.util.Arrays) Tuple(au.gov.asd.tac.constellation.utilities.datastructure.Tuple) MarkerUtilities(au.gov.asd.tac.constellation.views.mapview.utilities.MarkerUtilities) ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) PApplet(processing.core.PApplet) GraphElement(au.gov.asd.tac.constellation.views.mapview.utilities.GraphElement) Set(java.util.Set) HashMap(java.util.HashMap) PGraphics(processing.core.PGraphics) Marker(de.fhpotsdam.unfolding.marker.Marker) PImage(processing.core.PImage) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) PConstants(processing.core.PConstants) List(java.util.List) Location(de.fhpotsdam.unfolding.geo.Location) Map(java.util.Map) ScreenPosition(de.fhpotsdam.unfolding.utils.ScreenPosition) ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) HashMap(java.util.HashMap) PGraphics(processing.core.PGraphics) ArrayList(java.util.ArrayList) Marker(de.fhpotsdam.unfolding.marker.Marker) ScreenPosition(de.fhpotsdam.unfolding.utils.ScreenPosition) GraphElement(au.gov.asd.tac.constellation.views.mapview.utilities.GraphElement) Tuple(au.gov.asd.tac.constellation.utilities.datastructure.Tuple) Location(de.fhpotsdam.unfolding.geo.Location)

Example 5 with Location

use of de.fhpotsdam.unfolding.geo.Location in project constellation by constellation-app.

the class DayNightLayer method update.

@Override
public PImage update() {
    final int width = renderer.width - 5;
    final int height = renderer.height - 5;
    final PGraphics dayNightImage = renderer.createGraphics(width, height, PConstants.JAVA2D);
    dayNightImage.beginDraw();
    final long currentTime = System.currentTimeMillis();
    final Location sunLocation = getSunPosition(currentTime);
    final ScreenPosition sunPosition = map.getScreenPosition(sunLocation);
    final Location leftShadowLocation = getShadowPosition(sunLocation, ShadowOrientation.LEFT);
    final Location rightShadowLocation = getShadowPosition(sunLocation, ShadowOrientation.RIGHT);
    // draw the sun
    dayNightImage.stroke(STROKE_COLOR);
    dayNightImage.fill(SUN_COLOR);
    dayNightImage.ellipse(sunPosition.x, sunPosition.y, 10, 10);
    // calculate shadow radius
    final float twighlightCivilRadiusMeters = getShadowRadiusFromAngle(0.566666);
    final float twighlightNauticalRadiusMeters = getShadowRadiusFromAngle(6.0);
    final float twighlightAstronomicalRadiusMeters = getShadowRadiusFromAngle(12.0);
    final float nightRadiusMeters = getShadowRadiusFromAngle(18.0);
    // left twilight civil
    final Location leftTwighlightCivilRadiusLocation = new Location(leftShadowLocation.getLat() - Distance.Haversine.kilometersToDecimalDegrees(twighlightCivilRadiusMeters / 1000), leftShadowLocation.getLon() - Distance.Haversine.kilometersToDecimalDegrees(twighlightCivilRadiusMeters / 1000));
    final List<Location> leftTwighlightCivilLocations = MarkerUtilities.generateCircle(leftShadowLocation, leftTwighlightCivilRadiusLocation);
    final List<MapPosition> leftTwighlightCivilPositions = leftTwighlightCivilLocations.stream().map(location -> new MapPosition(map.mapDisplay.getObjectFromLocation(location))).collect(Collectors.toList());
    dayNightImage.noStroke();
    dayNightImage.fill(TWIGHLIGHT_CIVIL_COLOR);
    dayNightImage.beginShape();
    leftTwighlightCivilPositions.forEach(position -> dayNightImage.vertex(position.x, position.y));
    dayNightImage.endShape(PConstants.CLOSE);
    // left twilight nautical
    final Location leftTwighlightNauticalRadiusLocation = new Location(leftShadowLocation.getLat() - Distance.Haversine.kilometersToDecimalDegrees(twighlightNauticalRadiusMeters / 1000), leftShadowLocation.getLon() - Distance.Haversine.kilometersToDecimalDegrees(twighlightNauticalRadiusMeters / 1000));
    final List<Location> leftTwighlightNauticalLocations = MarkerUtilities.generateCircle(leftShadowLocation, leftTwighlightNauticalRadiusLocation);
    final List<MapPosition> leftTwighlightNauticalPositions = leftTwighlightNauticalLocations.stream().map(location -> new MapPosition(map.mapDisplay.getObjectFromLocation(location))).collect(Collectors.toList());
    dayNightImage.noStroke();
    dayNightImage.fill(TWIGHLIGHT_NAUTICAL_COLOR);
    dayNightImage.beginShape();
    leftTwighlightNauticalPositions.forEach(position -> dayNightImage.vertex(position.x, position.y));
    dayNightImage.endShape(PConstants.CLOSE);
    // left twilight astronomical
    final Location leftTwighlightAstronomicalRadiusLocation = new Location(leftShadowLocation.getLat() + Distance.Haversine.kilometersToDecimalDegrees(twighlightAstronomicalRadiusMeters / 1000), leftShadowLocation.getLon() + Distance.Haversine.kilometersToDecimalDegrees(twighlightAstronomicalRadiusMeters / 1000));
    final List<Location> leftTwighlightAstronomicalLocations = MarkerUtilities.generateCircle(leftShadowLocation, leftTwighlightAstronomicalRadiusLocation);
    final List<MapPosition> leftTwighlightAstronomicalPositions = leftTwighlightAstronomicalLocations.stream().map(location -> new MapPosition(map.mapDisplay.getObjectFromLocation(location))).collect(Collectors.toList());
    dayNightImage.noStroke();
    dayNightImage.fill(TWIGHLIGHT_ASTRONOMICAL_COLOR);
    dayNightImage.beginShape();
    leftTwighlightAstronomicalPositions.forEach(position -> dayNightImage.vertex(position.x, position.y));
    dayNightImage.endShape(PConstants.CLOSE);
    // left night
    final Location leftNightRadiusLocation = new Location(leftShadowLocation.getLat() + Distance.Haversine.kilometersToDecimalDegrees(nightRadiusMeters / 1000), leftShadowLocation.getLon() + Distance.Haversine.kilometersToDecimalDegrees(nightRadiusMeters / 1000));
    final List<Location> leftNightLocations = MarkerUtilities.generateCircle(leftShadowLocation, leftNightRadiusLocation);
    final List<MapPosition> leftNightPositions = leftNightLocations.stream().map(location -> new MapPosition(map.mapDisplay.getObjectFromLocation(location))).collect(Collectors.toList());
    dayNightImage.noStroke();
    dayNightImage.fill(NIGHT_COLOR);
    dayNightImage.beginShape();
    leftNightPositions.forEach(position -> dayNightImage.vertex(position.x, position.y));
    dayNightImage.endShape(PConstants.CLOSE);
    // right twilight civil
    final Location rightTwighlightCivilRadiusLocation = new Location(rightShadowLocation.getLat() - Distance.Haversine.kilometersToDecimalDegrees(twighlightCivilRadiusMeters / 1000), rightShadowLocation.getLon() - Distance.Haversine.kilometersToDecimalDegrees(twighlightCivilRadiusMeters / 1000));
    final List<Location> rightTwighlightCivilLocations = MarkerUtilities.generateCircle(rightShadowLocation, rightTwighlightCivilRadiusLocation);
    final List<MapPosition> rightTwighlightCivilPositions = rightTwighlightCivilLocations.stream().map(location -> new MapPosition(map.mapDisplay.getObjectFromLocation(location))).collect(Collectors.toList());
    dayNightImage.noStroke();
    dayNightImage.fill(TWIGHLIGHT_CIVIL_COLOR);
    dayNightImage.beginShape();
    rightTwighlightCivilPositions.forEach(position -> dayNightImage.vertex(position.x, position.y));
    dayNightImage.endShape(PConstants.CLOSE);
    // right twilight nautical
    final Location rightTwighlightNauticalRadiusLocation = new Location(rightShadowLocation.getLat() - Distance.Haversine.kilometersToDecimalDegrees(twighlightNauticalRadiusMeters / 1000), rightShadowLocation.getLon() - Distance.Haversine.kilometersToDecimalDegrees(twighlightNauticalRadiusMeters / 1000));
    final List<Location> rightTwighlightNauticalLocations = MarkerUtilities.generateCircle(rightShadowLocation, rightTwighlightNauticalRadiusLocation);
    final List<MapPosition> rightTwighlightNauticalPositions = rightTwighlightNauticalLocations.stream().map(location -> new MapPosition(map.mapDisplay.getObjectFromLocation(location))).collect(Collectors.toList());
    dayNightImage.noStroke();
    dayNightImage.fill(TWIGHLIGHT_NAUTICAL_COLOR);
    dayNightImage.beginShape();
    rightTwighlightNauticalPositions.forEach(position -> dayNightImage.vertex(position.x, position.y));
    dayNightImage.endShape(PConstants.CLOSE);
    // right twilight astronomical
    final Location rightTwighlightAstronomicalRadiusLocation = new Location(rightShadowLocation.getLat() + Distance.Haversine.kilometersToDecimalDegrees(twighlightAstronomicalRadiusMeters / 1000), rightShadowLocation.getLon() + Distance.Haversine.kilometersToDecimalDegrees(twighlightAstronomicalRadiusMeters / 1000));
    final List<Location> rightTwighlightAstronomicalLocations = MarkerUtilities.generateCircle(rightShadowLocation, rightTwighlightAstronomicalRadiusLocation);
    final List<MapPosition> rightTwighlightAstronomicalPositions = rightTwighlightAstronomicalLocations.stream().map(location -> new MapPosition(map.mapDisplay.getObjectFromLocation(location))).collect(Collectors.toList());
    dayNightImage.noStroke();
    dayNightImage.fill(TWIGHLIGHT_ASTRONOMICAL_COLOR);
    dayNightImage.beginShape();
    rightTwighlightAstronomicalPositions.forEach(position -> dayNightImage.vertex(position.x, position.y));
    dayNightImage.endShape(PConstants.CLOSE);
    // right night
    final Location rightNightRadiusLocation = new Location(rightShadowLocation.getLat() + Distance.Haversine.kilometersToDecimalDegrees(nightRadiusMeters / 1000), rightShadowLocation.getLon() + Distance.Haversine.kilometersToDecimalDegrees(nightRadiusMeters / 1000));
    final List<Location> rightNightLocations = MarkerUtilities.generateCircle(rightShadowLocation, rightNightRadiusLocation);
    final List<MapPosition> rightNightPositions = rightNightLocations.stream().map(location -> new MapPosition(map.mapDisplay.getObjectFromLocation(location))).collect(Collectors.toList());
    dayNightImage.noStroke();
    dayNightImage.fill(NIGHT_COLOR);
    dayNightImage.beginShape();
    rightNightPositions.forEach(position -> dayNightImage.vertex(position.x, position.y));
    dayNightImage.endShape(PConstants.CLOSE);
    dayNightImage.endDraw();
    return dayNightImage;
}
Also used : PConstants(processing.core.PConstants) Distance(au.gov.asd.tac.constellation.utilities.geospatial.Distance) List(java.util.List) MarkerUtilities(au.gov.asd.tac.constellation.views.mapview.utilities.MarkerUtilities) Location(de.fhpotsdam.unfolding.geo.Location) ServiceProvider(org.openide.util.lookup.ServiceProvider) ScreenPosition(de.fhpotsdam.unfolding.utils.ScreenPosition) PGraphics(processing.core.PGraphics) PImage(processing.core.PImage) MapPosition(de.fhpotsdam.unfolding.utils.MapPosition) Collectors(java.util.stream.Collectors) PGraphics(processing.core.PGraphics) ScreenPosition(de.fhpotsdam.unfolding.utils.ScreenPosition) MapPosition(de.fhpotsdam.unfolding.utils.MapPosition) Location(de.fhpotsdam.unfolding.geo.Location)

Aggregations

Location (de.fhpotsdam.unfolding.geo.Location)24 ArrayList (java.util.ArrayList)7 MarkerUtilities (au.gov.asd.tac.constellation.views.mapview.utilities.MarkerUtilities)6 List (java.util.List)6 Collectors (java.util.stream.Collectors)6 ConstellationAbstractMarker (au.gov.asd.tac.constellation.views.mapview.markers.ConstellationAbstractMarker)5 PConstants (processing.core.PConstants)5 PGraphics (processing.core.PGraphics)5 ConstellationPointFeature (au.gov.asd.tac.constellation.views.mapview.features.ConstellationPointFeature)4 MapPosition (de.fhpotsdam.unfolding.utils.MapPosition)4 ScreenPosition (de.fhpotsdam.unfolding.utils.ScreenPosition)4 Graph (au.gov.asd.tac.constellation.graph.Graph)3 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)3 GraphElement (au.gov.asd.tac.constellation.views.mapview.utilities.GraphElement)3 MarkerCache (au.gov.asd.tac.constellation.views.mapview.utilities.MarkerCache)3 UnfoldingMap (de.fhpotsdam.unfolding.UnfoldingMap)3 PanMapEvent (de.fhpotsdam.unfolding.events.PanMapEvent)3 ZoomMapEvent (de.fhpotsdam.unfolding.events.ZoomMapEvent)3 Marker (de.fhpotsdam.unfolding.marker.Marker)3 HashMap (java.util.HashMap)3