Search in sources :

Example 26 with Coord

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

the class HousenumberIvl method getInterpolatedHouses.

public List<HousenumberMatch> getInterpolatedHouses() {
    List<HousenumberMatch> houses = new ArrayList<>();
    if (ignoreForInterpolation || start == end || steps <= 0)
        return houses;
    List<Coord> interpolatedPoints = getInterpolatedPoints();
    int usedStep = (start < end) ? step : -step;
    int hn = start;
    boolean distanceWarningIssued = false;
    CityInfo ci = knownHouses[0].getCityInfo();
    ZipCodeInfo zip = knownHouses[0].getZipCode();
    if (ci != null && ci.equals(knownHouses[1].getCityInfo()) == false)
        log.warn("addr:interpolation way connects houses in different cities", streetName, this, "using city", ci, "for all interpolated adresses");
    if (zip != null && zip.equals(knownHouses[1].getZipCode()) == false)
        log.warn("addr:interpolation way connects houses with differnt zip codes", streetName, this, "using zip code", zip, "for all interpolated adresses");
    for (Coord co : interpolatedPoints) {
        hn += usedStep;
        Node generated = new Node(interpolationWay.getId(), co);
        generated.setFakeId();
        generated.addTag(streetTagKey, streetName);
        String number = String.valueOf(hn);
        generated.addTag(housenumberTagKey, number);
        // TODO: maybe add check that city info and zip code of both houses is equal ?
        // what if not ?
        HousenumberElem houseElem = new HousenumberElem(generated, ci);
        houseElem.setHousenumber(hn);
        houseElem.setZipCode(zip);
        houseElem.setStreet(streetName);
        houseElem.setSign(number);
        HousenumberMatch house = new HousenumberMatch(houseElem);
        if (roadForInterpolatedHouses != null) {
            HousenumberGenerator.findClosestRoadSegment(house, roadForInterpolatedHouses);
            if (house.getRoad() == null || house.getDistance() > MAX_INTERPOLATION_DISTANCE_TO_ROAD) {
                if (distanceWarningIssued == false) {
                    log.warn("interpolated house is not close to expected road", this, house);
                    distanceWarningIssued = true;
                }
                continue;
            }
            house.calcRoadSide();
        }
        house.setInterpolated(true);
        houses.add(house);
    }
    if (log.isDebugEnabled()) {
        String addrInterpolationMethod = interpolationWay.getTag(addrInterpolationTagKey);
        if (hasMultipleRoads == false)
            log.debug(this, "generated", addrInterpolationMethod, "interpolated number(s) for", knownHouses[0].getRoad());
        else
            log.debug(this, "generated", addrInterpolationMethod, "interpolated number(s) for", streetName);
    }
    return houses;
}
Also used : Coord(uk.me.parabola.imgfmt.app.Coord) CityInfo(uk.me.parabola.mkgmap.general.CityInfo) ZipCodeInfo(uk.me.parabola.mkgmap.general.ZipCodeInfo) Node(uk.me.parabola.mkgmap.reader.osm.Node) ArrayList(java.util.ArrayList)

Example 27 with Coord

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

the class HousenumberMatch method calcRoadSide.

public void calcRoadSide() {
    if (getRoad() == null)
        return;
    Coord c1 = getRoad().getPoints().get(getSegment());
    Coord c2 = getRoad().getPoints().get(getSegment() + 1);
    setLeft(HousenumberGenerator.isLeft(c1, c2, getLocation()));
}
Also used : Coord(uk.me.parabola.imgfmt.app.Coord)

Example 28 with Coord

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

the class HousenumberMatch method isDirectlyConnected.

public boolean isDirectlyConnected(HousenumberMatch other) {
    if (getElement() instanceof Way && other.getElement() instanceof Way) {
        List<Coord> s1 = ((Way) getElement()).getPoints();
        List<Coord> s2 = ((Way) other.getElement()).getPoints();
        for (int i = 0; i + 1 < s1.size(); i++) {
            Coord co = s1.get(i);
            co.setPartOfShape2(false);
        }
        for (int i = 0; i + 1 < s2.size(); i++) {
            Coord co = s2.get(i);
            co.setPartOfShape2(true);
        }
        for (int i = 0; i + 1 < s1.size(); i++) {
            Coord co = s1.get(i);
            if (co.isPartOfShape2())
                return true;
        }
    }
    return false;
}
Also used : Coord(uk.me.parabola.imgfmt.app.Coord) Way(uk.me.parabola.mkgmap.reader.osm.Way)

Example 29 with Coord

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

the class HousenumberRoad method buildIntervals.

public void buildIntervals() {
    Collections.sort(houseNumbers, new HousenumberMatchByNumComparator());
    if (log.isInfoEnabled())
        log.info("Initial housenumbers for", road, "in", road.getCity(), houseNumbers);
    filterRealDuplicates();
    filterGroups();
    if (houseNumbers.isEmpty())
        return;
    List<HousenumberMatch> leftNumbers = new ArrayList<HousenumberMatch>();
    List<HousenumberMatch> rightNumbers = new ArrayList<HousenumberMatch>();
    for (HousenumberMatch house : houseNumbers) {
        if (house.getRoad() == null || house.isIgnored()) {
            continue;
        }
        if (house.getHousenumberRoad() != this || house.getHousenumberRoad().getRoad() != house.getRoad()) {
            log.error("internal error, road links are not correct", house.toBrowseURL());
        }
        if (house.isLeft()) {
            leftNumbers.add(house);
        } else {
            rightNumbers.add(house);
        }
    }
    detectGroups(leftNumbers, rightNumbers);
    Collections.sort(leftNumbers, new HousenumberMatchByPosComparator());
    Collections.sort(rightNumbers, new HousenumberMatchByPosComparator());
    int currNodePos = 0;
    int nodeIndex = 0;
    int prevNumberNodeIndex = 0;
    int prevNodePos = 0;
    extNumbersHead = null;
    ExtNumbers currNumbers = null;
    for (Coord p : road.getPoints()) {
        if (currNodePos == 0) {
            if (road.skipAddToNOD() == false)
                assert p instanceof CoordNode;
        }
        // An ordinary point in the road.
        if (p.isNumberNode() == false) {
            currNodePos++;
            continue;
        }
        // The first time round, this is guaranteed to be a CoordNode
        if (currNodePos == 0) {
            nodeIndex++;
            currNodePos++;
            continue;
        }
        // Now we have a CoordNode and it is not the first one.
        ExtNumbers numbers = new ExtNumbers(this);
        numbers.setNodeIndex(prevNumberNodeIndex);
        int leftUsed = numbers.setNumbers(leftNumbers, prevNodePos, currNodePos, true);
        int rightUsed = numbers.setNumbers(rightNumbers, prevNodePos, currNodePos, false);
        prevNodePos = currNodePos;
        // maintain chain
        numbers.prev = currNumbers;
        if (currNumbers != null)
            currNumbers.next = numbers;
        else {
            extNumbersHead = numbers;
        }
        currNumbers = numbers;
        leftNumbers.subList(0, leftUsed).clear();
        rightNumbers.subList(0, rightUsed).clear();
        prevNumberNodeIndex = nodeIndex;
        nodeIndex++;
        currNodePos++;
    }
}
Also used : Coord(uk.me.parabola.imgfmt.app.Coord) HousenumberMatchByPosComparator(uk.me.parabola.mkgmap.osmstyle.housenumber.HousenumberGenerator.HousenumberMatchByPosComparator) HousenumberMatchByNumComparator(uk.me.parabola.mkgmap.osmstyle.housenumber.HousenumberGenerator.HousenumberMatchByNumComparator) ArrayList(java.util.ArrayList) CoordNode(uk.me.parabola.imgfmt.app.CoordNode)

Example 30 with Coord

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

the class MapperBasedMapDataSource method addBoundaryLine.

public void addBoundaryLine(Area area, int type, String name) {
    List<Coord> coords = new ArrayList<Coord>();
    coords.add(new Coord(area.getMinLat(), area.getMinLong()));
    coords.add(new Coord(area.getMinLat(), area.getMaxLong()));
    coords.add(new Coord(area.getMaxLat(), area.getMaxLong()));
    coords.add(new Coord(area.getMaxLat(), area.getMinLong()));
    coords.add(new Coord(area.getMinLat() + 1, area.getMinLong()));
    MapLine boundary = new MapLine();
    boundary.setType(type);
    if (name != null)
        boundary.setName(name);
    // On all levels
    boundary.setMinResolution(0);
    boundary.setPoints(coords);
    mapper.addLine(boundary);
}
Also used : Coord(uk.me.parabola.imgfmt.app.Coord) MapLine(uk.me.parabola.mkgmap.general.MapLine) ArrayList(java.util.ArrayList)

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