Search in sources :

Example 66 with Coord

use of uk.me.parabola.imgfmt.app.Coord in project mkgmap by openstreetmap.

the class Polyline method getNodeCount.

/**
 * @param countAllNodes : false: count only coord nodes, true: count number nodes
 * @return
 */
public int getNodeCount(boolean countAllNodes) {
    int idx = 0;
    int count = 0;
    for (Coord co : points) {
        if (idx++ > 0 && (co.getId() > 0 || countAllNodes && co.isNumberNode()))
            count++;
    }
    return count;
}
Also used : Coord(uk.me.parabola.imgfmt.app.Coord)

Example 67 with Coord

use of uk.me.parabola.imgfmt.app.Coord in project mkgmap by openstreetmap.

the class RuleFileReaderTest method getWayForClosedCompleteCheck.

/**
 * Get a way with a few points for testing the closed and complete flag.
 * @param closed way should be closed
 * @param complete way should not be complete
 */
private Way getWayForClosedCompleteCheck(boolean closed, boolean complete) {
    Way el = new Way(1);
    el.addTag("A", "B");
    el.addPoint(new Coord(1000, 1000));
    el.addPoint(new Coord(1000, 2000));
    el.addPoint(new Coord(2000, 2000));
    el.addPoint(new Coord(2000, 1000));
    if (closed)
        el.addPoint(el.getPoints().get(0));
    el.setComplete(complete);
    el.setClosedInOSM(true);
    return el;
}
Also used : Coord(uk.me.parabola.imgfmt.app.Coord) Way(uk.me.parabola.mkgmap.reader.osm.Way)

Example 68 with Coord

use of uk.me.parabola.imgfmt.app.Coord in project mkgmap by openstreetmap.

the class StyledConverterTest method makeConverter.

private StyledConverter makeConverter(String name) throws FileNotFoundException {
    Style style = new StyleImpl(LOC, name);
    MapCollector coll = new MapCollector() {

        public void addToBounds(Coord p) {
        }

        // could save points in the same way as lines to test them
        public void addPoint(MapPoint point) {
        }

        public void addLine(MapLine line) {
            // Save line so that it can be examined in the tests.
            assertNotNull("points are not null", line.getPoints());
            lines.add(line);
        }

        public void addShape(MapShape shape) {
        }

        public void addRoad(MapRoad road) {
            lines.add(road);
        }

        public int addRestriction(GeneralRouteRestriction grr) {
            return 0;
        }

        public void addThroughRoute(int junctionNodeId, long roadIdA, long roadIdB) {
        }
    };
    return new StyledConverter(style, coll, new EnhancedProperties());
}
Also used : Coord(uk.me.parabola.imgfmt.app.Coord) EnhancedProperties(uk.me.parabola.util.EnhancedProperties) MapLine(uk.me.parabola.mkgmap.general.MapLine) MapPoint(uk.me.parabola.mkgmap.general.MapPoint) GeneralRouteRestriction(uk.me.parabola.imgfmt.app.net.GeneralRouteRestriction) Style(uk.me.parabola.mkgmap.reader.osm.Style) MapRoad(uk.me.parabola.mkgmap.general.MapRoad) MapCollector(uk.me.parabola.mkgmap.general.MapCollector) MapShape(uk.me.parabola.mkgmap.general.MapShape)

Example 69 with Coord

use of uk.me.parabola.imgfmt.app.Coord in project mkgmap by openstreetmap.

the class QuadTree method isCloseToPolygon.

private static boolean isCloseToPolygon(Coord point, List<Coord> polygon, int gap) {
    Iterator<Coord> polyIter = polygon.iterator();
    Coord c2 = polyIter.next();
    while (polyIter.hasNext()) {
        Coord c1 = c2;
        c2 = polyIter.next();
        double dist = point.shortestDistToLineSegment(c1, c2);
        if (dist <= gap) {
            return true;
        }
    }
    return false;
}
Also used : Coord(uk.me.parabola.imgfmt.app.Coord)

Example 70 with Coord

use of uk.me.parabola.imgfmt.app.Coord in project mkgmap by openstreetmap.

the class QuadTreeNode method get.

public ArrayList<Coord> get(QuadTreePolygon polygon, ArrayList<Coord> resultList) {
    if (polygon.getBbox().intersects(getBounds())) {
        if (isLeaf()) {
            for (Coord c : points) {
                if (polygon.getArea().contains(c.getLongitude(), c.getLatitude())) {
                    resultList.add(c);
                }
            }
        } else {
            for (QuadTreeNode child : children) {
                if (polygon.getBbox().intersects(child.getBounds())) {
                    java.awt.geom.Area subArea = (java.awt.geom.Area) polygon.getArea().clone();
                    subArea.intersect(createArea(child.getBounds()));
                    child.get(new QuadTreePolygon(subArea), resultList);
                }
            }
        }
    }
    return resultList;
}
Also used : Coord(uk.me.parabola.imgfmt.app.Coord) Area(uk.me.parabola.imgfmt.app.Area) java.awt(java.awt)

Aggregations

Coord (uk.me.parabola.imgfmt.app.Coord)178 ArrayList (java.util.ArrayList)71 Way (uk.me.parabola.mkgmap.reader.osm.Way)31 MapPoint (uk.me.parabola.mkgmap.general.MapPoint)27 List (java.util.List)23 MapLine (uk.me.parabola.mkgmap.general.MapLine)16 Area (uk.me.parabola.imgfmt.app.Area)15 MapShape (uk.me.parabola.mkgmap.general.MapShape)15 CoordNode (uk.me.parabola.imgfmt.app.CoordNode)13 MapExitPoint (uk.me.parabola.mkgmap.general.MapExitPoint)13 Node (uk.me.parabola.mkgmap.reader.osm.Node)13 HashMap (java.util.HashMap)12 IdentityHashMap (java.util.IdentityHashMap)11 Test (org.junit.Test)11 MapRoad (uk.me.parabola.mkgmap.general.MapRoad)9 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)8 Area (java.awt.geom.Area)8 HashSet (java.util.HashSet)8 IntArrayList (it.unimi.dsi.fastutil.ints.IntArrayList)5 LinkedHashMap (java.util.LinkedHashMap)5