Search in sources :

Example 11 with AiLatLng

use of org.activityinfo.model.type.geo.AiLatLng in project activityinfo by bedatadriven.

the class TileMath method tileBounds.

public static Extents tileBounds(int zoom, int x, int y) {
    Point upperLeft = pointForTile(new Tile(x, y));
    Point lowerRight = pointForTile(new Tile(x + 1, y + 1));
    AiLatLng northWest = inverse(upperLeft, zoom);
    AiLatLng southEast = inverse(lowerRight, zoom);
    return new Extents(southEast.getLat(), northWest.getLat(), northWest.getLng(), southEast.getLng());
}
Also used : AiLatLng(org.activityinfo.model.type.geo.AiLatLng) Point(org.activityinfo.legacy.shared.reports.content.Point) Extents(org.activityinfo.model.type.geo.Extents)

Example 12 with AiLatLng

use of org.activityinfo.model.type.geo.AiLatLng in project activityinfo by bedatadriven.

the class LocationForm method addCoordFields.

private void addCoordFields() {
    coordinateFields = new CoordinateFields();
    coordinateFields.setToolTip(I18N.CONSTANTS.coordinateToolTip());
    add(coordinateFields.getLatitudeField());
    add(coordinateFields.getLongitudeField());
    newLocationPresenter.addListener(NewLocationPresenter.POSITION_CHANGED, new Listener<BaseEvent>() {

        @Override
        public void handleEvent(BaseEvent be) {
            if (!newLocationPresenter.isProvisional()) {
                coordinateFields.setValue(newLocationPresenter.getLatLng());
            }
        }
    });
    coordinateFields.addChangeListener(new Listener<FieldEvent>() {

        @Override
        public void handleEvent(FieldEvent be) {
            AiLatLng value = coordinateFields.getValue();
            if (value != null) {
                newLocationPresenter.setLatLng(value);
            }
        }
    });
}
Also used : AiLatLng(org.activityinfo.model.type.geo.AiLatLng) CoordinateFields(org.activityinfo.ui.client.widget.coord.CoordinateFields)

Example 13 with AiLatLng

use of org.activityinfo.model.type.geo.AiLatLng in project activityinfo by bedatadriven.

the class TileMathTest method inverse.

@Test
public void inverse() {
    AiLatLng latlng = new AiLatLng(15, 30);
    Point px = TileMath.fromLatLngToPixel(latlng, 6);
    AiLatLng inverse = TileMath.inverse(px, 6);
    assertThat("longitude", inverse.getLng(), equalTo(latlng.getLng()));
    assertThat("latitude", inverse.getLat(), closeTo(latlng.getLat(), 0.0001));
}
Also used : AiLatLng(org.activityinfo.model.type.geo.AiLatLng) Point(org.activityinfo.legacy.shared.reports.content.Point) Test(org.junit.Test)

Example 14 with AiLatLng

use of org.activityinfo.model.type.geo.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;
            AiLatLng geoPoint = getPoint(site);
            if (geoPoint != null) {
                px = map.fromLatLngToPixel(geoPoint);
            }
            Double value = getValue(site, layer.getIndicatorIds());
            if (value != null && value != 0) {
                PointValue pv = new PointValue(site, createSymbol(site, layer.getColorDimensions()), value, px);
                if (geoPoint != null || clusterer.isMapped(site)) {
                    mapped.add(pv);
                } else {
                    unmapped.add(pv);
                }
            }
        }
    }
}
Also used : PointValue(org.activityinfo.legacy.shared.reports.model.PointValue) AiLatLng(org.activityinfo.model.type.geo.AiLatLng) SiteDTO(org.activityinfo.legacy.shared.model.SiteDTO)

Example 15 with AiLatLng

use of org.activityinfo.model.type.geo.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.model.type.geo.AiLatLng) TiledMap(org.activityinfo.server.report.generator.map.TiledMap)

Aggregations

AiLatLng (org.activityinfo.model.type.geo.AiLatLng)19 PointValue (org.activityinfo.legacy.shared.reports.model.PointValue)7 SiteDTO (org.activityinfo.legacy.shared.model.SiteDTO)6 Point (org.activityinfo.legacy.shared.reports.content.Point)5 Cluster (org.activityinfo.server.report.generator.map.cluster.Cluster)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)3 MapContent (org.activityinfo.legacy.shared.reports.content.MapContent)3 Indicator (org.activityinfo.server.database.hibernate.entity.Indicator)3 Clusterer (org.activityinfo.server.report.generator.map.cluster.Clusterer)3 PieMapMarker (org.activityinfo.legacy.shared.reports.content.PieMapMarker)2 MapReportElement (org.activityinfo.legacy.shared.reports.model.MapReportElement)2 MapSymbol (org.activityinfo.legacy.shared.reports.model.MapSymbol)2 PiechartMapLayer (org.activityinfo.legacy.shared.reports.model.layers.PiechartMapLayer)2 Extents (org.activityinfo.model.type.geo.Extents)2 BaseEvent (com.extjs.gxt.ui.client.event.BaseEvent)1 StoreEvent (com.extjs.gxt.ui.client.store.StoreEvent)1 BufferedReader (java.io.BufferedReader)1 FileOutputStream (java.io.FileOutputStream)1 InputStreamReader (java.io.InputStreamReader)1