Search in sources :

Example 1 with ExtTypeAttributes

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

the class StyledConverter method elementSetup.

private static void elementSetup(MapElement ms, GType gt, Element element) {
    String[] labels = new String[4];
    int noLabels = 0;
    for (int labelNo = 0; labelNo < 4; labelNo++) {
        String label1 = element.getTag(labelTagKeys[labelNo]);
        String label = Label.squashSpaces(label1);
        if (label != null) {
            labels[noLabels] = label;
            noLabels++;
        }
    }
    if (labels[0] != null) {
        ms.setLabels(labels);
    }
    ms.setType(gt.getType());
    ms.setMinResolution(gt.getMinResolution());
    ms.setMaxResolution(gt.getMaxResolution());
    if (element.tagIsLikeYes(highResOnlyTagKey)) {
        ms.setMinResolution(ms.getMaxResolution());
    }
    if (ms instanceof MapLine && element.tagIsLikeYes(skipSizeFilterTagKey)) {
        ((MapLine) ms).setSkipSizeFilter(true);
    }
    // Now try to get some address info for POIs
    String country = element.getTag(countryTagKey);
    String region = element.getTag(regionTagKey);
    String city = element.getTag(cityTagKey);
    String zip = element.getTag(postal_codeTagKey);
    String street = element.getTag(streetTagKey);
    String houseNumber = element.getTag(housenumberTagKey);
    String phone = element.getTag(phoneTagKey);
    String isIn = element.getTag(is_inTagKey);
    if (country != null)
        ms.setCountry(country);
    if (region != null)
        ms.setRegion(region);
    if (city != null)
        ms.setCity(city);
    if (zip != null)
        ms.setZip(zip);
    if (street != null)
        ms.setStreet(street);
    if (houseNumber != null)
        ms.setHouseNumber(houseNumber);
    if (isIn != null)
        ms.setIsIn(isIn);
    if (phone != null)
        ms.setPhone(phone);
    if (MapObject.hasExtendedType(gt.getType())) {
        // pass attributes with mkgmap:xt- prefix (strip prefix)
        Map<String, String> xta = element.getTagsWithPrefix("mkgmap:xt-", true);
        // also pass all attributes with seamark: prefix (no strip prefix)
        xta.putAll(element.getTagsWithPrefix("seamark:", false));
        ms.setExtTypeAttributes(new ExtTypeAttributes(xta, "OSM id " + element.getId()));
    }
}
Also used : MapLine(uk.me.parabola.mkgmap.general.MapLine) ExtTypeAttributes(uk.me.parabola.imgfmt.app.trergn.ExtTypeAttributes) MapPoint(uk.me.parabola.mkgmap.general.MapPoint) MapExitPoint(uk.me.parabola.mkgmap.general.MapExitPoint)

Example 2 with ExtTypeAttributes

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

the class PolishMapDataSource method makeExtTypeAttributes.

private ExtTypeAttributes makeExtTypeAttributes() {
    Map<String, String> eta = new HashMap<>();
    int colour = 0;
    int style = 0;
    for (Map.Entry<String, String> entry : extraAttributes.entrySet()) {
        String v = entry.getValue();
        if (entry.getKey().equals("Depth")) {
            String u = extraAttributes.get("DepthUnit");
            if ("f".equals(u))
                v += "ft";
            eta.put("depth", v);
        } else if (entry.getKey().equals("Height")) {
            String u = extraAttributes.get("HeightUnit");
            if ("f".equals(u))
                v += "ft";
            eta.put("height", v);
        } else if (entry.getKey().equals("HeightAboveFoundation")) {
            String u = extraAttributes.get("HeightAboveFoundationUnit");
            if ("f".equals(u))
                v += "ft";
            eta.put("height-above-foundation", v);
        } else if (entry.getKey().equals("HeightAboveDatum")) {
            String u = extraAttributes.get("HeightAboveDatumUnit");
            if ("f".equals(u))
                v += "ft";
            eta.put("height-above-datum", v);
        } else if (entry.getKey().equals("Color")) {
            colour = Integer.decode(v);
        } else if (entry.getKey().equals("Style")) {
            style = Integer.decode(v);
        } else if (entry.getKey().equals("Position")) {
            eta.put("position", v);
        } else if (entry.getKey().equals("FoundationColor")) {
            eta.put("color", v);
        } else if (entry.getKey().equals("Light")) {
            eta.put("light", v);
        } else if (entry.getKey().equals("LightType")) {
            eta.put("type", v);
        } else if (entry.getKey().equals("Period")) {
            eta.put("period", v);
        } else if (entry.getKey().equals("Note")) {
            eta.put("note", v);
        } else if (entry.getKey().equals("LocalDesignator")) {
            eta.put("local-desig", v);
        } else if (entry.getKey().equals("InternationalDesignator")) {
            eta.put("int-desig", v);
        } else if (entry.getKey().equals("FacilityPoint")) {
            eta.put("facilities", v);
        } else if (entry.getKey().equals("Racon")) {
            eta.put("racon", v);
        } else if (entry.getKey().equals("LeadingAngle")) {
            eta.put("leading-angle", v);
        }
    }
    if (colour != 0 || style != 0)
        eta.put("style", "0x" + Integer.toHexString((style << 8) | colour));
    return new ExtTypeAttributes(eta, "Line " + lineNo);
}
Also used : HashMap(java.util.HashMap) Long2ObjectOpenHashMap(it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap) ExtTypeAttributes(uk.me.parabola.imgfmt.app.trergn.ExtTypeAttributes) HashMap(java.util.HashMap) Long2ObjectOpenHashMap(it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap) Map(java.util.Map) MapPoint(uk.me.parabola.mkgmap.general.MapPoint)

Example 3 with ExtTypeAttributes

use of uk.me.parabola.imgfmt.app.trergn.ExtTypeAttributes 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

ExtTypeAttributes (uk.me.parabola.imgfmt.app.trergn.ExtTypeAttributes)3 MapPoint (uk.me.parabola.mkgmap.general.MapPoint)3 MapExitPoint (uk.me.parabola.mkgmap.general.MapExitPoint)2 Long2ObjectOpenHashMap (it.unimi.dsi.fastutil.longs.Long2ObjectOpenHashMap)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Coord (uk.me.parabola.imgfmt.app.Coord)1 Exit (uk.me.parabola.imgfmt.app.Exit)1 City (uk.me.parabola.imgfmt.app.lbl.City)1 LBLFile (uk.me.parabola.imgfmt.app.lbl.LBLFile)1 POIRecord (uk.me.parabola.imgfmt.app.lbl.POIRecord)1 Point (uk.me.parabola.imgfmt.app.trergn.Point)1 MapLine (uk.me.parabola.mkgmap.general.MapLine)1