Search in sources :

Example 11 with Extents

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

the class GetAdminEntitiesHandler method toEntity.

public static AdminEntityDTO toEntity(SqlResultSetRow row) {
    AdminEntityDTO entity = new AdminEntityDTO();
    entity.setId(row.getInt("adminEntityId"));
    entity.setName(row.getString("name"));
    entity.setLevelId(row.getInt("adminLevelId"));
    entity.setLevelName(row.getString("levelName"));
    if (!row.isNull("adminEntityParentId")) {
        entity.setParentId(row.getInt("adminEntityParentId"));
    }
    Extents bounds = Extents.empty();
    if (!row.isNull("x1")) {
        bounds.setMinLon(row.getDouble("x1"));
        bounds.setMinLat(row.getDouble("y1"));
        bounds.setMaxLon(row.getDouble("x2"));
        bounds.setMaxLat(row.getDouble("y2"));
        entity.setBounds(bounds);
    }
    return entity;
}
Also used : AdminEntityDTO(org.activityinfo.legacy.shared.model.AdminEntityDTO) Extents(org.activityinfo.model.type.geo.Extents)

Example 12 with Extents

use of org.activityinfo.model.type.geo.Extents 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 13 with Extents

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

the class LocationMap method afterRender.

@Override
protected void afterRender() {
    super.afterRender();
    Extents countryBounds = searchPresenter.getCountryBounds();
    MapOptions mapOptions = new MapOptions();
    mapOptions.setCenter(new LatLng(countryBounds.getCenterY(), countryBounds.getCenterX()));
    mapOptions.setZoom(6);
    mapOptions.setProperty("crs", new EPSG3857());
    TileLayer baseLayer = new TileLayer(MapboxLayers.MAPBOX_STREETS, new Options());
    markerLayer = new LayerGroup(new ILayer[0]);
    map = new Map(getElement().getElementsByTagName("div").getItem(0), mapOptions);
    map.addLayer(baseLayer);
    map.addLayer(markerLayer);
    bindEvents();
}
Also used : EPSG3857(org.discotools.gwt.leaflet.client.crs.epsg.EPSG3857) MapOptions(org.discotools.gwt.leaflet.client.map.MapOptions) Options(org.discotools.gwt.leaflet.client.Options) TileLayer(org.discotools.gwt.leaflet.client.layers.raster.TileLayer) MapOptions(org.discotools.gwt.leaflet.client.map.MapOptions) ILayer(org.discotools.gwt.leaflet.client.layers.ILayer) AiLatLng(org.activityinfo.model.type.geo.AiLatLng) LayerGroup(org.discotools.gwt.leaflet.client.layers.others.LayerGroup) Extents(org.activityinfo.model.type.geo.Extents) Map(org.discotools.gwt.leaflet.client.map.Map)

Example 14 with Extents

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

the class TableMappingBuilder method addGeoAreaField.

public void addGeoAreaField(FormField field) {
    add(new FieldMapping(field, Arrays.asList("x1", "y1", "x2", "y2"), new FieldValueConverter() {

        @Override
        public FieldValue toFieldValue(ResultSet rs, int index) throws SQLException {
            double x1 = rs.getDouble(index);
            if (rs.wasNull()) {
                return null;
            }
            double y1 = rs.getDouble(index + 1);
            if (rs.wasNull()) {
                return null;
            }
            double x2 = rs.getDouble(index + 2);
            if (rs.wasNull()) {
                return null;
            }
            double y2 = rs.getDouble(index + 3);
            if (rs.wasNull()) {
                return null;
            }
            return new GeoArea(Extents.create(x1, y1, x2, y2), "FIXME");
        }

        @Override
        public Collection<? extends Object> toParameters(FieldValue value) {
            GeoArea area = (GeoArea) value;
            Extents bbox = area.getEnvelope();
            return Arrays.asList(bbox.getX1(), bbox.getY1(), bbox.getX2(), bbox.getY2());
        }
    }));
}
Also used : GeoArea(org.activityinfo.model.type.geo.GeoArea) ResultSet(java.sql.ResultSet) FieldValue(org.activityinfo.model.type.FieldValue) Extents(org.activityinfo.model.type.geo.Extents)

Example 15 with Extents

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

the class ItextReportRendererTest method legendTest.

@Test
public void legendTest() throws IOException {
    BubbleMapMarker marker1 = new BubbleMapMarker();
    marker1.setLat(-2.45);
    marker1.setLng(28.8);
    marker1.setX(100);
    marker1.setY(100);
    marker1.setRadius(25);
    marker1.setValue(300);
    TileBaseMap baseMap = new TileBaseMap();
    baseMap.setTileUrlPattern("//www.activityinfo.org/resources/tile/nordkivu.cd/{z}/{x}/{y}.png");
    BubbleMapLayer layer1 = new BubbleMapLayer();
    layer1.addIndicatorId(101);
    layer1.setMinRadius(10);
    layer1.setMaxRadius(10);
    BubbleLayerLegend legend1 = new BubbleLayerLegend();
    legend1.setDefinition(layer1);
    legend1.setMinValue(1000);
    legend1.setMaxValue(3000);
    BubbleMapLayer layer2 = new BubbleMapLayer();
    layer2.addIndicatorId(102);
    layer2.addIndicatorId(103);
    layer2.setMinRadius(10);
    layer2.setMaxRadius(25);
    BubbleLayerLegend legend2 = new BubbleLayerLegend();
    legend2.setDefinition(layer2);
    legend2.setMinValue(600);
    legend2.setMaxValue(999);
    IconMapLayer layer3 = new IconMapLayer();
    layer3.setIcon(MapIcon.Icon.Default.name());
    layer3.getIndicatorIds().add(101);
    IconLayerLegend legend3 = new IconLayerLegend();
    legend3.setDefinition(layer3);
    List<PieChartLegend> pieChartLegends = Lists.newArrayList();
    List<PiechartMapLayer> pieChartLayers = Lists.newArrayList();
    int[] indicatorIds = new int[] { 101, 102, 103 };
    for (int sliceCount = 1; sliceCount < 10; ++sliceCount) {
        PiechartMapLayer pieChartLayer = new PiechartMapLayer();
        for (int i = 0; i != sliceCount; ++i) {
            pieChartLayer.addIndicatorId(indicatorIds[i % indicatorIds.length]);
        }
        pieChartLayer.setMinRadius(25);
        pieChartLayer.setMaxRadius(25);
        PieChartLegend pieChartLegend = new PieChartLegend();
        pieChartLegend.setDefinition(pieChartLayer);
        pieChartLayers.add(pieChartLayer);
        pieChartLegends.add(pieChartLegend);
    }
    IndicatorDTO indicator101 = new IndicatorDTO();
    indicator101.setId(101);
    indicator101.setName("Nombre de salles de classe fonctionnelles (construites, rehabilitees, equipees) " + "pour l'education formelle et non formelle.");
    IndicatorDTO indicator102 = new IndicatorDTO();
    indicator102.setId(102);
    indicator102.setName("Nombre d'enfants ayant beneficie de kits scolaires, recreatifs et didactiques");
    IndicatorDTO indicator103 = new IndicatorDTO();
    indicator103.setId(103);
    indicator103.setName("Pourcentage des ménages qui utilsent la moustiquaire rationnellement");
    MapContent mapContent = new MapContent();
    mapContent.setFilterDescriptions(Collections.EMPTY_LIST);
    mapContent.setBaseMap(baseMap);
    mapContent.setZoomLevel(8);
    mapContent.setCenter(new Extents(-2.2, -2.1, 28.85, 28.9).center());
    mapContent.setMarkers(Arrays.asList((MapMarker) marker1));
    mapContent.getIndicators().addAll(Arrays.asList(indicator101, indicator102, indicator103));
    mapContent.addLegend(legend1);
    mapContent.addLegend(legend2);
    mapContent.addLegend(legend3);
    mapContent.getLegends().addAll(pieChartLegends);
    MapReportElement map = new MapReportElement();
    map.setTitle("My Map");
    map.setContent(mapContent);
    map.addLayer(layer1);
    map.addLayer(layer2);
    map.addLayer(layer3);
    map.getLayers().addAll(pieChartLayers);
    ReportContent content = new ReportContent();
    content.setFilterDescriptions(Collections.EMPTY_LIST);
    Report report = new Report();
    report.setContent(content);
    report.addElement(map);
    renderToPdf(report, "legend.pdf");
    renderToHtml(report, "legend.html");
    renderToRtf(report, "legend.rtf");
}
Also used : IconMapLayer(org.activityinfo.legacy.shared.reports.model.layers.IconMapLayer) BubbleMapLayer(org.activityinfo.legacy.shared.reports.model.layers.BubbleMapLayer) Extents(org.activityinfo.model.type.geo.Extents) IndicatorDTO(org.activityinfo.legacy.shared.model.IndicatorDTO) TileBaseMap(org.activityinfo.legacy.shared.model.TileBaseMap) PiechartMapLayer(org.activityinfo.legacy.shared.reports.model.layers.PiechartMapLayer) Test(org.junit.Test)

Aggregations

Extents (org.activityinfo.model.type.geo.Extents)16 TileBaseMap (org.activityinfo.legacy.shared.model.TileBaseMap)5 Test (org.junit.Test)5 AiLatLng (org.activityinfo.model.type.geo.AiLatLng)3 BaseMap (org.activityinfo.legacy.shared.model.BaseMap)2 IconMapLayer (org.activityinfo.legacy.shared.reports.model.layers.IconMapLayer)2 Envelope (com.vividsolutions.jts.geom.Envelope)1 ResultSet (java.sql.ResultSet)1 AdminEntity (org.activityinfo.geoadmin.model.AdminEntity)1 AdminLevel (org.activityinfo.geoadmin.model.AdminLevel)1 DimensionType (org.activityinfo.legacy.shared.command.DimensionType)1 Filter (org.activityinfo.legacy.shared.command.Filter)1 CreateResult (org.activityinfo.legacy.shared.command.result.CreateResult)1 AdminEntityDTO (org.activityinfo.legacy.shared.model.AdminEntityDTO)1 HasAdminEntityValues (org.activityinfo.legacy.shared.model.HasAdminEntityValues)1 IndicatorDTO (org.activityinfo.legacy.shared.model.IndicatorDTO)1 GoogleBaseMap (org.activityinfo.legacy.shared.reports.content.GoogleBaseMap)1 MapContent (org.activityinfo.legacy.shared.reports.content.MapContent)1 MapMarker (org.activityinfo.legacy.shared.reports.content.MapMarker)1 Point (org.activityinfo.legacy.shared.reports.content.Point)1