Search in sources :

Example 6 with Point

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();
}
Also used : AiLatLng(org.activityinfo.shared.report.content.AiLatLng) Point(org.activityinfo.shared.report.content.Point) Point(org.activityinfo.shared.report.content.Point)

Example 7 with Point

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;
}
Also used : AiLatLng(org.activityinfo.shared.report.content.AiLatLng) Point(org.activityinfo.shared.report.content.Point) Point(org.activityinfo.shared.report.content.Point)

Example 8 with Point

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());
}
Also used : AiLatLng(org.activityinfo.shared.report.content.AiLatLng) Point(org.activityinfo.shared.report.content.Point)

Example 9 with Point

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);
}
Also used : Point(org.activityinfo.shared.report.content.Point) Test(org.junit.Test)

Example 10 with Point

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);
}
Also used : Point(org.activityinfo.shared.report.content.Point) Test(org.junit.Test)

Aggregations

Point (org.activityinfo.shared.report.content.Point)21 AiLatLng (org.activityinfo.shared.report.content.AiLatLng)10 PointValue (org.activityinfo.shared.report.model.PointValue)10 ArrayList (java.util.ArrayList)7 Cluster (org.activityinfo.server.report.generator.map.cluster.Cluster)6 Test (org.junit.Test)6 SiteDTO (org.activityinfo.shared.dto.SiteDTO)4 Clusterer (org.activityinfo.server.report.generator.map.cluster.Clusterer)3 MarkerGraph (org.activityinfo.server.report.generator.map.cluster.genetic.MarkerGraph)2 BubbleMapMarker (org.activityinfo.shared.report.content.BubbleMapMarker)2 MapSymbol (org.activityinfo.shared.report.model.MapSymbol)2 Coordinate (com.vividsolutions.jts.geom.Coordinate)1 CoordinateArraySequence (com.vividsolutions.jts.geom.impl.CoordinateArraySequence)1 File (java.io.File)1 FileWriter (java.io.FileWriter)1 List (java.util.List)1 BubbleFitnessFunctor (org.activityinfo.server.report.generator.map.cluster.genetic.BubbleFitnessFunctor)1 GeneticSolver (org.activityinfo.server.report.generator.map.cluster.genetic.GeneticSolver)1 IntersectionCalculator (org.activityinfo.server.report.generator.map.cluster.genetic.MarkerGraph.IntersectionCalculator)1 Node (org.activityinfo.server.report.generator.map.cluster.genetic.MarkerGraph.Node)1