Search in sources :

Example 11 with AiLatLng

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

the class GeometryProjecter method transformCoordinates.

@Override
protected CoordinateSequence transformCoordinates(CoordinateSequence coords, Geometry parent) {
    int n = coords.size();
    Coordinate[] outCoords = new Coordinate[n];
    int outIndex = 0;
    for (int i = 0; i != n; ++i) {
        Point px = map.fromLatLngToPixel(new AiLatLng(coords.getY(i), coords.getX(i)));
        outCoords[outIndex] = new Coordinate(px.getDoubleX(), px.getDoubleY());
        outIndex++;
    }
    return new CoordinateArraySequence(Arrays.copyOf(outCoords, outIndex));
}
Also used : Coordinate(com.vividsolutions.jts.geom.Coordinate) AiLatLng(org.activityinfo.shared.report.content.AiLatLng) Point(org.activityinfo.shared.report.content.Point) Point(org.activityinfo.shared.report.content.Point) CoordinateArraySequence(com.vividsolutions.jts.geom.impl.CoordinateArraySequence)

Example 12 with AiLatLng

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

the class TileMath method zoomLevelForExtents.

/**
 * Returns the maximum zoom level at which the given extents will fit inside
 * the map of the given size
 *
 * @param extent
 * @param mapWidth
 * @param mapHeight
 * @return
 */
public static int zoomLevelForExtents(Extents extent, int mapWidth, int mapHeight) {
    int zoomLevel = 1;
    do {
        Point upperLeft = fromLatLngToPixel(new AiLatLng(extent.getMaxLat(), extent.getMinLon()), zoomLevel);
        Point lowerRight = fromLatLngToPixel(new AiLatLng(extent.getMinLat(), extent.getMaxLon()), zoomLevel);
        int extentWidth = lowerRight.getX() - upperLeft.getX();
        if (extentWidth > mapWidth) {
            return zoomLevel - 1;
        }
        int extentHeight = lowerRight.getY() - upperLeft.getY();
        if (extentHeight > mapHeight) {
            return zoomLevel - 1;
        }
        zoomLevel++;
    } while (zoomLevel < MAX_ZOOM);
    return zoomLevel;
}
Also used : AiLatLng(org.activityinfo.shared.report.content.AiLatLng) Point(org.activityinfo.shared.report.content.Point) Point(org.activityinfo.shared.report.content.Point)

Example 13 with AiLatLng

use of org.activityinfo.shared.report.content.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.shared.report.content.AiLatLng) Point(org.activityinfo.shared.report.content.Point)

Example 14 with AiLatLng

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

the class PieMapMarkerTest method testPies.

@Test
public void testPies() {
    Dimension dimension = new Dimension(DimensionType.Indicator);
    dimension.setCategoryColor(101, 255);
    dimension.setCategoryColor(102, 0x00FF00);
    dimension.setCategoryColor(103, 0x0000FF);
    SiteDTO site1 = new SiteDTO();
    site1.setId(1);
    site1.setX(0d);
    site1.setY(0d);
    site1.setIndicatorValue(101, 50d);
    site1.setIndicatorValue(102, 40d);
    site1.setIndicatorValue(103, 10d);
    List<SiteDTO> sites = new ArrayList<SiteDTO>();
    sites.add(site1);
    PiechartMapLayer layer = new PiechartMapLayer();
    layer.addIndicatorId(101);
    layer.addIndicatorId(102);
    layer.addIndicatorId(103);
    // layer.getColorDimensions().add(dimension);
    MapReportElement mapElement = new MapReportElement();
    mapElement.addLayer(layer);
    MapContent content = new MapContent();
    TiledMap map = new TiledMap(640, 480, new AiLatLng(0, 0), 6);
    Map<Integer, Indicator> indicators = Maps.newHashMap();
    indicators.put(101, new Indicator());
    indicators.put(102, new Indicator());
    indicators.put(103, new Indicator());
    PiechartLayerGenerator generator = new PiechartLayerGenerator(layer, indicators);
    generator.setSites(sites);
    generator.generate(map, content);
    Assert.assertEquals(1, content.getMarkers().size());
    PieMapMarker marker = (PieMapMarker) content.getMarkers().get(0);
    Assert.assertEquals(3, marker.getSlices().size());
}
Also used : MapContent(org.activityinfo.shared.report.content.MapContent) ArrayList(java.util.ArrayList) Dimension(org.activityinfo.shared.report.model.Dimension) Indicator(org.activityinfo.server.database.hibernate.entity.Indicator) MapReportElement(org.activityinfo.shared.report.model.MapReportElement) PieMapMarker(org.activityinfo.shared.report.content.PieMapMarker) AiLatLng(org.activityinfo.shared.report.content.AiLatLng) SiteDTO(org.activityinfo.shared.dto.SiteDTO) PiechartMapLayer(org.activityinfo.shared.report.model.layers.PiechartMapLayer) Test(org.junit.Test)

Example 15 with AiLatLng

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

the class PolygonGeneratorTest method polygonWithHole.

@Test
public void polygonWithHole() throws IOException {
    AdminMarker marker = new AdminMarker();
    marker.setAdminEntityId(1930);
    marker.setColor("#FFBBBB");
    AdminOverlay overlay = new AdminOverlay(1383);
    overlay.setOutlineColor("#FF0000");
    overlay.addPolygon(marker);
    PolygonMapLayer layer = new PolygonMapLayer();
    layer.addIndicatorId(1);
    layer.setAdminLevelId(1383);
    MapContent content = new MapContent();
    content.setZoomLevel(8);
    content.setBaseMap(GoogleBaseMap.ROADMAP);
    content.setCenter(new AiLatLng(12.60500192642215, -7.98924994468689));
    content.getAdminOverlays().add(overlay);
    content.setFilterDescriptions(new ArrayList<FilterDescription>());
    PolygonLegend.ColorClass clazz1 = new PolygonLegend.ColorClass(1, 53.6, "0000FF");
    PolygonLegend.ColorClass clazz2 = new PolygonLegend.ColorClass(600, 600, "FF0000");
    PolygonLegend legend = new PolygonLegend(layer, Lists.newArrayList(clazz1, clazz2));
    content.getLegends().add(legend);
    IndicatorDTO indicator = new IndicatorDTO();
    indicator.setId(1);
    indicator.setName("Indicator Test");
    content.getIndicators().add(indicator);
    MapReportElement map = new MapReportElement();
    map.addLayer(layer);
    map.setContent(content);
    FileOutputStream fos = new FileOutputStream("target/report-tests/polygon-hole.pdf");
    PdfReportRenderer pdfr = new PdfReportRenderer(TestGeometry.get(), "");
    pdfr.render(map, fos);
    fos.close();
}
Also used : PolygonMapLayer(org.activityinfo.shared.report.model.layers.PolygonMapLayer) MapContent(org.activityinfo.shared.report.content.MapContent) PdfReportRenderer(org.activityinfo.server.report.renderer.itext.PdfReportRenderer) FilterDescription(org.activityinfo.shared.report.content.FilterDescription) MapReportElement(org.activityinfo.shared.report.model.MapReportElement) IndicatorDTO(org.activityinfo.shared.dto.IndicatorDTO) AdminOverlay(org.activityinfo.shared.report.content.AdminOverlay) PolygonLegend(org.activityinfo.shared.report.content.PolygonLegend) AdminMarker(org.activityinfo.shared.report.content.AdminMarker) FileOutputStream(java.io.FileOutputStream) AiLatLng(org.activityinfo.shared.report.content.AiLatLng) Test(org.junit.Test)

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