use of org.activityinfo.shared.report.content.Point in project activityinfo by bedatadriven.
the class PathUtils method addRingToPath.
private static void addRingToPath(TiledMap map, GeneralPath path, Coordinate[] coordinates) {
System.out.println("--ring--");
float lastX = Float.NaN;
float lastY = Float.NaN;
for (int j = 0; j != coordinates.length; ++j) {
Point point = map.fromLatLngToPixel(new AiLatLng(coordinates[j].y, coordinates[j].x));
float x = point.getX();
float y = point.getY();
if (x != lastX || y != lastY) {
System.out.println(point.getX() + "," + point.getY());
if (j == 0) {
path.moveTo(x, y);
} else {
path.lineTo(x, y);
}
}
lastX = x;
lastY = y;
}
path.closePath();
}
use of org.activityinfo.shared.report.content.Point 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.Point 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.Point in project activityinfo by bedatadriven.
the class CircleMathTest method testCompletelyContained.
@Test
public void testCompletelyContained() {
Point a = new Point(297, 212);
Point b = new Point(295, 213);
Assert.assertEquals(CircleMath.area(5), CircleMath.intersectionArea(a, b, 8, 5), DELTA);
}
use of org.activityinfo.shared.report.content.Point in project activityinfo by bedatadriven.
the class CircleMathTest method testNoIntersection.
@Test
public void testNoIntersection() {
Point a = new Point(0, 0);
Point b = new Point(5, 0);
Assert.assertEquals(0.0, CircleMath.intersectionArea(a, b, 1, 2), DELTA);
}
Aggregations