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;
}
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()));
}
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;
}
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++;
}
}
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);
}
Aggregations