Search in sources :

Example 16 with AiLatLng

use of org.activityinfo.shared.report.content.AiLatLng in project activityinfo by bedatadriven.

the class LocationMap method createNewLocationMarker.

private void createNewLocationMarker() {
    DivIcon icon = createIcon("");
    Options markerOptions = new Options();
    markerOptions.setProperty("icon", icon);
    markerOptions.setProperty("draggable", true);
    newLocationMarker = new Marker(newLatLng(newLocationPresenter.getLatLng()), markerOptions);
    EventHandlerManager.addEventHandler(newLocationMarker, org.discotools.gwt.leaflet.client.events.handler.EventHandler.Events.dragend, new EventHandler<Event>() {

        @Override
        public void handle(Event event) {
            newLocationPresenter.setLatLng(new AiLatLng(newLocationMarker.getLatLng().lat(), newLocationMarker.getLatLng().lng()));
        }
    });
    map.addLayer(newLocationMarker);
}
Also used : MapOptions(org.discotools.gwt.leaflet.client.map.MapOptions) Options(org.discotools.gwt.leaflet.client.Options) DivIconOptions(org.discotools.gwt.leaflet.client.types.DivIconOptions) MouseEvent(org.discotools.gwt.leaflet.client.events.MouseEvent) Event(org.discotools.gwt.leaflet.client.events.Event) StoreEvent(com.extjs.gxt.ui.client.store.StoreEvent) BaseEvent(com.extjs.gxt.ui.client.event.BaseEvent) AiLatLng(org.activityinfo.shared.report.content.AiLatLng) Marker(org.discotools.gwt.leaflet.client.marker.Marker) DivIcon(org.discotools.gwt.leaflet.client.types.DivIcon)

Example 17 with AiLatLng

use of org.activityinfo.shared.report.content.AiLatLng in project activityinfo by bedatadriven.

the class ImageMapRenderer method createTileMap.

protected TiledMap createTileMap(MapReportElement element) {
    AiLatLng center = element.getCenter() != null ? element.getCenter() : element.getContent().getCenter();
    TiledMap map = new TiledMap(element.getWidth(), element.getHeight(), center, element.getContent().getZoomLevel());
    return map;
}
Also used : AiLatLng(org.activityinfo.shared.report.content.AiLatLng) TiledMap(org.activityinfo.server.report.generator.map.TiledMap)

Example 18 with AiLatLng

use of org.activityinfo.shared.report.content.AiLatLng in project activityinfo by bedatadriven.

the class BubbleLayerGenerator method generatePoints.

public void generatePoints(List<SiteDTO> sites, TiledMap map, BubbleMapLayer layer, Clusterer clusterer, List<PointValue> mapped, List<PointValue> unmapped) {
    for (SiteDTO site : sites) {
        if (hasValue(site, layer.getIndicatorIds())) {
            Point px = null;
            if (site.hasLatLong()) {
                px = map.fromLatLngToPixel(new AiLatLng(site.getLatitude(), site.getLongitude()));
            }
            Double value = getValue(site, layer.getIndicatorIds());
            if (value != null && value != 0) {
                PointValue pv = new PointValue(site, createSymbol(site, layer.getColorDimensions()), value, px);
                // TODO: add AdminLevel to pointvalue
                if (clusterer.isMapped(site)) {
                    mapped.add(pv);
                } else {
                    unmapped.add(pv);
                }
            }
        }
    }
}
Also used : PointValue(org.activityinfo.shared.report.model.PointValue) AiLatLng(org.activityinfo.shared.report.content.AiLatLng) SiteDTO(org.activityinfo.shared.dto.SiteDTO) Point(org.activityinfo.shared.report.content.Point)

Example 19 with AiLatLng

use of org.activityinfo.shared.report.content.AiLatLng in project activityinfo by bedatadriven.

the class IconLayerGenerator method generate.

@Override
public void generate(TiledMap map, MapContent content) {
    List<PointValue> points = new ArrayList<PointValue>();
    IconRectCalculator rectCalculator = new IconRectCalculator(icon);
    IntersectionCalculator intersectionCalculator = new IntersectionCalculator() {

        @Override
        public boolean intersects(Node a, Node b) {
            return a.getPointValue().getIconRect().intersects(b.getPointValue().getIconRect());
        }
    };
    Clusterer clusterer = ClustererFactory.fromClustering(layer.getClustering(), rectCalculator, intersectionCalculator);
    for (SiteDTO site : sites) {
        if (meetsCriteria(site)) {
            if (clusterer.isMapped(site)) {
                Point point = null;
                if (site.hasLatLong()) {
                    point = map.fromLatLngToPixel(new AiLatLng(site.getLatitude(), site.getLongitude()));
                }
                points.add(new PointValue(site, point, point == null ? null : rectCalculator.iconRect(point), getValue(site, layer.getIndicatorIds())));
            } else {
                content.getUnmappedSites().add(site.getId());
            }
        }
    }
    List<Cluster> clusters = clusterer.cluster(map, points);
    createMarkersFrom(clusters, map, content);
    IconLayerLegend legend = new IconLayerLegend();
    legend.setDefinition(layer);
    content.addLegend(legend);
}
Also used : PointValue(org.activityinfo.shared.report.model.PointValue) Node(org.activityinfo.server.report.generator.map.cluster.genetic.MarkerGraph.Node) ArrayList(java.util.ArrayList) Cluster(org.activityinfo.server.report.generator.map.cluster.Cluster) Point(org.activityinfo.shared.report.content.Point) Clusterer(org.activityinfo.server.report.generator.map.cluster.Clusterer) IntersectionCalculator(org.activityinfo.server.report.generator.map.cluster.genetic.MarkerGraph.IntersectionCalculator) AiLatLng(org.activityinfo.shared.report.content.AiLatLng) SiteDTO(org.activityinfo.shared.dto.SiteDTO) IconLayerLegend(org.activityinfo.shared.report.content.IconLayerLegend)

Example 20 with AiLatLng

use of org.activityinfo.shared.report.content.AiLatLng in project activityinfo by bedatadriven.

the class PiechartLayerGenerator method generate.

@Override
public void generate(TiledMap map, MapContent content) {
    // create the list of input point values
    List<PointValue> points = new ArrayList<PointValue>();
    List<PointValue> unmapped = new ArrayList<PointValue>();
    // define our symbol scaling
    RadiiCalculator radiiCalculator;
    if (layer.getScaling() == ScalingType.None || layer.getMinRadius() == layer.getMaxRadius()) {
        radiiCalculator = new FixedRadiiCalculator(layer.getMinRadius());
    } else if (layer.getScaling() == ScalingType.Graduated) {
        radiiCalculator = new GsLogCalculator(layer.getMinRadius(), layer.getMaxRadius());
    } else {
        radiiCalculator = new FixedRadiiCalculator(layer.getMinRadius());
    }
    Clusterer clusterer = ClustererFactory.fromClustering(layer.getClustering(), radiiCalculator, new BubbleIntersectionCalculator(layer.getMaxRadius()));
    generatePoints(map, layer, clusterer, points, unmapped);
    // add unmapped sites
    for (PointValue pv : unmapped) {
        content.getUnmappedSites().add(pv.getSite().getId());
    }
    List<Cluster> clusters = clusterer.cluster(map, points);
    // create the markers
    List<BubbleMapMarker> markers = new ArrayList<BubbleMapMarker>();
    for (Cluster cluster : clusters) {
        Point px = cluster.getPoint();
        AiLatLng latlng = map.fromPixelToLatLng(px);
        BubbleMapMarker marker = new PieMapMarker();
        sumSlices((PieMapMarker) marker, cluster.getPointValues());
        for (PointValue pv : cluster.getPointValues()) {
            marker.getSiteIds().add(pv.getSite().getId());
        }
        marker.setX(px.getX());
        marker.setY(px.getY());
        marker.setValue(cluster.sumValues());
        marker.setRadius((int) cluster.getRadius());
        marker.setLat(latlng.getLat());
        marker.setLng(latlng.getLng());
        marker.setAlpha(layer.getAlpha());
        marker.setIndicatorIds(new HashSet<Integer>(layer.getIndicatorIds()));
        marker.setClusterAmount(cluster.getPointValues().size());
        marker.setClustering(layer.getClustering());
        markers.add(marker);
    }
    // number markers if applicable
    if (layer.getLabelSequence() != null) {
        numberMarkers(markers);
    }
    PieChartLegend legend = new PieChartLegend();
    legend.setDefinition(layer);
    content.getMarkers().addAll(markers);
    content.addLegend(legend);
}
Also used : PointValue(org.activityinfo.shared.report.model.PointValue) ArrayList(java.util.ArrayList) Cluster(org.activityinfo.server.report.generator.map.cluster.Cluster) BubbleMapMarker(org.activityinfo.shared.report.content.BubbleMapMarker) Point(org.activityinfo.shared.report.content.Point) PieChartLegend(org.activityinfo.shared.report.content.PieChartLegend) Clusterer(org.activityinfo.server.report.generator.map.cluster.Clusterer) PieMapMarker(org.activityinfo.shared.report.content.PieMapMarker) AiLatLng(org.activityinfo.shared.report.content.AiLatLng)

Aggregations

AiLatLng (org.activityinfo.shared.report.content.AiLatLng)22 Point (org.activityinfo.shared.report.content.Point)10 PointValue (org.activityinfo.shared.report.model.PointValue)7 ArrayList (java.util.ArrayList)6 SiteDTO (org.activityinfo.shared.dto.SiteDTO)6 Cluster (org.activityinfo.server.report.generator.map.cluster.Cluster)5 MapContent (org.activityinfo.shared.report.content.MapContent)5 Test (org.junit.Test)5 Indicator (org.activityinfo.server.database.hibernate.entity.Indicator)3 Clusterer (org.activityinfo.server.report.generator.map.cluster.Clusterer)3 PieMapMarker (org.activityinfo.shared.report.content.PieMapMarker)3 MapReportElement (org.activityinfo.shared.report.model.MapReportElement)3 PiechartMapLayer (org.activityinfo.shared.report.model.layers.PiechartMapLayer)3 BaseEvent (com.extjs.gxt.ui.client.event.BaseEvent)2 TiledMap (org.activityinfo.server.report.generator.map.TiledMap)2 BubbleMapMarker (org.activityinfo.shared.report.content.BubbleMapMarker)2 MapSymbol (org.activityinfo.shared.report.model.MapSymbol)2 FieldEvent (com.extjs.gxt.ui.client.event.FieldEvent)1 StoreEvent (com.extjs.gxt.ui.client.store.StoreEvent)1 Coordinate (com.vividsolutions.jts.geom.Coordinate)1