Search in sources :

Example 1 with MapExitPoint

use of uk.me.parabola.mkgmap.general.MapExitPoint in project mkgmap by openstreetmap.

the class StyledConverter method addPoint.

private void addPoint(Node node, GType gt) {
    if (!clipper.contains(node.getLocation()))
        return;
    // to handle exit points we use a subclass of MapPoint
    // to carry some extra info (a reference to the
    // motorway associated with the exit)
    MapPoint mp;
    int type = gt.getType();
    if (type >= 0x2000 && type < 0x2800) {
        String ref = node.getTag(Exit.TAG_ROAD_REF);
        String id = node.getTag("mkgmap:osmid");
        if (ref != null) {
            String to = node.getTag(Exit.TAG_TO);
            MapExitPoint mep = new MapExitPoint(ref, to);
            String fd = node.getTag(Exit.TAG_FACILITY);
            if (fd != null)
                mep.setFacilityDescription(fd);
            if (id != null)
                mep.setOSMId(id);
            mp = mep;
        } else {
            mp = new MapPoint();
            if ("motorway_junction".equals(node.getTag("highway")))
                log.warn("Motorway exit", node.getName(), "(" + node.toBrowseURL() + ") has no (motorway) ref! (either make the exit share a node with the motorway or specify the motorway ref with a", Exit.TAG_ROAD_REF, "tag)");
        }
    } else {
        mp = new MapPoint();
    }
    elementSetup(mp, gt, node);
    mp.setLocation(node.getLocation());
    boolean dupPOI = checkDuplicatePOI(mp);
    if (dupPOI) {
        if (log.isInfoEnabled()) {
            if (FakeIdGenerator.isFakeId(node.getId()))
                log.info("ignoring duplicate POI with type", GType.formatType(type), mp.getName(), "for generated element with id", node.getId(), "at", mp.getLocation().toDegreeString());
            else
                log.info("ignoring duplicate POI with type", GType.formatType(type), mp.getName(), "for element", node.toBrowseURL());
        }
        return;
    }
    collector.addPoint(mp);
}
Also used : MapExitPoint(uk.me.parabola.mkgmap.general.MapExitPoint) MapPoint(uk.me.parabola.mkgmap.general.MapPoint) MapPoint(uk.me.parabola.mkgmap.general.MapPoint) MapExitPoint(uk.me.parabola.mkgmap.general.MapExitPoint)

Example 2 with MapExitPoint

use of uk.me.parabola.mkgmap.general.MapExitPoint in project mkgmap by openstreetmap.

the class MapBuilder method processExit.

private void processExit(Map map, MapExitPoint mep) {
    LBLFile lbl = map.getLblFile();
    String ref = mep.getMotorwayRef();
    String OSMId = mep.getOSMId();
    if (ref != null) {
        Highway hw = highways.get(ref);
        if (hw == null)
            hw = makeHighway(map, ref);
        if (hw == null) {
            log.warn("Can't create exit", mep.getName(), "(OSM id", OSMId, ") on unknown highway", ref);
            return;
        }
        String exitName = mep.getName();
        String exitTo = mep.getTo();
        Exit exit = new Exit(hw);
        String facilityDescription = mep.getFacilityDescription();
        log.info("Creating", ref, "exit", exitName, "(OSM id", OSMId + ") to", exitTo, "with facility", ((facilityDescription == null) ? "(none)" : facilityDescription));
        if (facilityDescription != null) {
            // description is TYPE,DIR,FACILITIES,LABEL
            // (same as Polish Format)
            String[] atts = facilityDescription.split(",");
            int type = 0;
            if (atts.length > 0)
                type = Integer.decode(atts[0]);
            char direction = ' ';
            if (atts.length > 1) {
                direction = atts[1].charAt(0);
                if (direction == '\'' && atts[1].length() > 1)
                    direction = atts[1].charAt(1);
            }
            int facilities = 0x0;
            if (atts.length > 2)
                facilities = Integer.decode(atts[2]);
            String description = "";
            if (atts.length > 3)
                description = atts[3];
            // FIXME - handle multiple facilities?
            boolean last = true;
            ExitFacility ef = lbl.createExitFacility(type, direction, facilities, description, last);
            exit.addFacility(ef);
        }
        mep.setExit(exit);
        POIRecord r = lbl.createExitPOI(exitName, exit);
        if (exitTo != null) {
            Label ed = lbl.newLabel(exitTo);
            exit.setDescription(ed);
        }
        poimap.put(mep, r);
    // FIXME - set bottom bits of
    // type to reflect facilities available?
    }
}
Also used : Highway(uk.me.parabola.imgfmt.app.lbl.Highway) Label(uk.me.parabola.imgfmt.app.Label) POIRecord(uk.me.parabola.imgfmt.app.lbl.POIRecord) LBLFile(uk.me.parabola.imgfmt.app.lbl.LBLFile) MapPoint(uk.me.parabola.mkgmap.general.MapPoint) MapExitPoint(uk.me.parabola.mkgmap.general.MapExitPoint) Point(uk.me.parabola.imgfmt.app.trergn.Point) ExitFacility(uk.me.parabola.imgfmt.app.lbl.ExitFacility) Exit(uk.me.parabola.imgfmt.app.Exit)

Example 3 with MapExitPoint

use of uk.me.parabola.mkgmap.general.MapExitPoint in project mkgmap by openstreetmap.

the class MapBuilder method processPoints.

/**
 * Step through the points, filter and create a map point which is then added
 * to the map.
 *
 * Note that the location and resolution of map elements is relative to the
 * subdivision that they occur in.
 *
 * @param map	The map to add points to.
 * @param div	The subdivision that the points belong to.
 * @param points The points to be added.
 */
private void processPoints(Map map, Subdivision div, List<MapPoint> points) {
    LBLFile lbl = map.getLblFile();
    div.startPoints();
    int res = div.getResolution();
    boolean haveIndPoints = false;
    int pointIndex = 1;
    // points (not 1)
    for (MapPoint point : points) {
        if (point.isCity() && point.getMinResolution() <= res) {
            ++pointIndex;
            haveIndPoints = true;
        }
    }
    for (MapPoint point : points) {
        if (point.isCity() || point.getMinResolution() > res)
            continue;
        String name = point.getName();
        Point p = div.createPoint(name);
        p.setType(point.getType());
        if (point.hasExtendedType()) {
            ExtTypeAttributes eta = point.getExtTypeAttributes();
            if (eta != null) {
                eta.processLabels(lbl);
                p.setExtTypeAttributes(eta);
            }
        }
        Coord coord = point.getLocation();
        try {
            p.setLatitude(coord.getLatitude());
            p.setLongitude(coord.getLongitude());
        } catch (AssertionError ae) {
            log.error("Problem with point of type 0x" + Integer.toHexString(point.getType()) + " at " + coord.toOSMURL());
            log.error("  Subdivision shift is " + div.getShift() + " and its centre is at " + div.getCenter().toOSMURL());
            log.error("  " + ae.getMessage());
            continue;
        }
        POIRecord r = poimap.get(point);
        if (r != null)
            p.setPOIRecord(r);
        map.addMapObject(p);
        if (!point.hasExtendedType()) {
            if (name != null && div.getZoom().getLevel() == 0) {
                if (pointIndex > 255)
                    log.error("Too many POIs at location " + div.getCenter().toOSMURL() + " - " + name + " will be ignored");
                else if (point.isExit()) {
                    Exit e = ((MapExitPoint) point).getExit();
                    if (e != null)
                        e.getHighway().addExitPoint(name, pointIndex, div);
                } else if (makePOIIndex)
                    lbl.createPOIIndex(name, pointIndex, div, point.getType());
            }
            ++pointIndex;
        }
    }
    if (haveIndPoints) {
        div.startIndPoints();
        // reset to 1
        pointIndex = 1;
        for (MapPoint point : points) {
            if (!point.isCity() || point.getMinResolution() > res)
                continue;
            String name = point.getName();
            Point p = div.createPoint(name);
            p.setType(point.getType());
            Coord coord = point.getLocation();
            try {
                p.setLatitude(coord.getLatitude());
                p.setLongitude(coord.getLongitude());
            } catch (AssertionError ae) {
                log.error("Problem with point of type 0x" + Integer.toHexString(point.getType()) + " at " + coord.toOSMURL());
                log.error("  Subdivision shift is " + div.getShift() + " and its centre is at " + div.getCenter().toOSMURL());
                log.error("  " + ae.getMessage());
                continue;
            }
            map.addMapObject(p);
            if (name != null && div.getZoom().getLevel() == 0) {
                // retrieve the City created earlier for this
                // point and store the point info in it
                City c = cityMap.get(point);
                if (pointIndex > 255) {
                    System.err.println("Can't set city point index for " + name + " (too many indexed points in division)\n");
                } else {
                    c.setPointIndex((byte) pointIndex);
                    c.setSubdivision(div);
                }
            }
            ++pointIndex;
        }
    }
}
Also used : Coord(uk.me.parabola.imgfmt.app.Coord) MapPoint(uk.me.parabola.mkgmap.general.MapPoint) ExtTypeAttributes(uk.me.parabola.imgfmt.app.trergn.ExtTypeAttributes) POIRecord(uk.me.parabola.imgfmt.app.lbl.POIRecord) LBLFile(uk.me.parabola.imgfmt.app.lbl.LBLFile) MapPoint(uk.me.parabola.mkgmap.general.MapPoint) MapExitPoint(uk.me.parabola.mkgmap.general.MapExitPoint) Point(uk.me.parabola.imgfmt.app.trergn.Point) City(uk.me.parabola.imgfmt.app.lbl.City) MapPoint(uk.me.parabola.mkgmap.general.MapPoint) MapExitPoint(uk.me.parabola.mkgmap.general.MapExitPoint) Point(uk.me.parabola.imgfmt.app.trergn.Point) Exit(uk.me.parabola.imgfmt.app.Exit)

Aggregations

MapExitPoint (uk.me.parabola.mkgmap.general.MapExitPoint)3 MapPoint (uk.me.parabola.mkgmap.general.MapPoint)3 Exit (uk.me.parabola.imgfmt.app.Exit)2 LBLFile (uk.me.parabola.imgfmt.app.lbl.LBLFile)2 POIRecord (uk.me.parabola.imgfmt.app.lbl.POIRecord)2 Point (uk.me.parabola.imgfmt.app.trergn.Point)2 Coord (uk.me.parabola.imgfmt.app.Coord)1 Label (uk.me.parabola.imgfmt.app.Label)1 City (uk.me.parabola.imgfmt.app.lbl.City)1 ExitFacility (uk.me.parabola.imgfmt.app.lbl.ExitFacility)1 Highway (uk.me.parabola.imgfmt.app.lbl.Highway)1 ExtTypeAttributes (uk.me.parabola.imgfmt.app.trergn.ExtTypeAttributes)1