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));
}
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;
}
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());
}
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());
}
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();
}
Aggregations