use of uk.me.parabola.imgfmt.app.trergn.Point in project mkgmap by openstreetmap.
the class MDRFile method addPoint.
public void addPoint(Point point, Mdr5Record city, boolean isCity) {
assert currentMap > 0;
int fullType = point.getType();
if (!MdrUtils.canBeIndexed(fullType))
return;
if (!poiExclTypes.isEmpty()) {
int t = (fullType < 0xff) ? fullType << 8 : fullType;
if (poiExclTypes.contains(t))
return;
}
Label label = point.getLabel();
String name = label.getText();
int strOff = createString(name);
Mdr11Record poi = mdr11.addPoi(currentMap, point, name, strOff);
poi.setCity(city);
poi.setIsCity(isCity);
poi.setType(fullType);
mdr4.addType(fullType);
}
use of uk.me.parabola.imgfmt.app.trergn.Point in project mkgmap by openstreetmap.
the class SimpleTest method testBasic.
/**
* A very basic check that the size of all the sections has not changed.
* This can be used to make sure that a change that is not expected to
* change the output does not do so.
*
* The sizes will have to be always changed when the output does change
* though.
*/
@Test
public void testBasic() throws FileNotFoundException {
Main.mainNoSystemExit(Args.TEST_STYLE_ARG, "--preserve-element-order", Args.TEST_RESOURCE_OSM + "uk-test-1.osm.gz");
MapReader mr = new MapReader(Args.DEF_MAP_ID + ".img");
TestUtils.registerFile(mr);
// FileSystem fs = ImgFS.openFs(Args.DEF_MAP_ID + ".img");
assertNotNull("file exists", mr);
Area bounds = mr.getTreBounds();
Area expBox = new Area(2402404, -11185, 2407064, -6524);
assertEquals("bounds of map", expBox, bounds);
List<Point> list = mr.pointsForLevel(0, MapReader.WITH_EXT_TYPE_DATA);
assertEquals("number of points at level 0", 204, list.size());
List<Polyline> list1 = mr.linesForLevel(0);
assertEquals("number of lines at level 0", 3382, list1.size());
}
use of uk.me.parabola.imgfmt.app.trergn.Point in project mkgmap by openstreetmap.
the class MapBuilder method preserveHorizontalAndVerticalLines.
/**
* Preserve shape points which a) lie on the shape boundary or
* b) which appear multiple times in the shape (excluding the start
* point which should always be identical to the end point).
* The preserved points are kept treated specially in the
* Line-Simplification-Filters, this should avoid artifacts like
* white triangles in the sea for lower resolutions.
* @param res the current resolution
* @param shapes list of shapes
*/
private static void preserveHorizontalAndVerticalLines(int res, List<MapShape> shapes) {
if (res == 24)
return;
for (MapShape shape : shapes) {
if (shape.getMinResolution() > res)
continue;
int minLat = shape.getBounds().getMinLat();
int maxLat = shape.getBounds().getMaxLat();
int minLon = shape.getBounds().getMinLong();
int maxLon = shape.getBounds().getMaxLong();
List<Coord> points = shape.getPoints();
int n = shape.getPoints().size();
IdentityHashMap<Coord, Coord> coords = new IdentityHashMap<>(n);
Coord first = points.get(0);
Coord prev = first;
Coord last = first;
for (int i = 1; i < points.size(); ++i) {
last = points.get(i);
// to connect holes
if (coords.get(last) == null) {
coords.put(last, last);
} else {
if (!last.preserved()) {
last.preserved(true);
}
}
// on the bbox of the shape.
if (last.getLatitude() == prev.getLatitude() && (last.getLatitude() == minLat || last.getLatitude() == maxLat) || last.getLongitude() == prev.getLongitude() && (last.getLongitude() == minLon || last.getLongitude() == maxLon)) {
last.preserved(true);
prev.preserved(true);
}
prev = last;
}
}
}
use of uk.me.parabola.imgfmt.app.trergn.Point in project mkgmap by openstreetmap.
the class MdrBuilder method addPoints.
/**
* Read points from this map and add them to the index.
* @param mr The currently open map.
* @param maps Maps of regions, cities countries etc.
*/
private void addPoints(MapReader mr, AreaMaps maps) {
List<Point> list = mr.pointsForLevel(0, MapReader.WITHOUT_EXT_TYPE_DATA);
for (Point p : list) {
Label label = p.getLabel();
if (p.getNumber() > 256) {
continue;
}
Mdr5Record mdrCity = null;
boolean isCity;
if (p.getType() >= 0x1 && p.getType() <= 0x11) {
// This is itself a city, it gets a reference to its own MDR 5 record.
// and we also use it to set the name of the city.
mdrCity = maps.cities.get((p.getSubdiv().getNumber() << 8) + p.getNumber());
if (mdrCity != null) {
mdrCity.setLblOffset(label.getOffset());
mdrCity.setName(label.getText());
}
isCity = true;
} else {
// This is not a city, but we have information about which city
// it is in. If so then add the mdr5 record number of the city.
POIRecord poi = p.getPOIRecord();
City c = poi.getCity();
if (c != null)
mdrCity = getMdr5FromCity(maps, c);
isCity = false;
}
if (label != null && !label.getText().trim().isEmpty())
mdrFile.addPoint(p, mdrCity, isCity);
}
}
use of uk.me.parabola.imgfmt.app.trergn.Point in project mkgmap by openstreetmap.
the class OverviewBuilder method readPoints.
/**
* Read the points from the .img file and add them to the overview map.
* We read from the least detailed level (apart from the empty one).
*
* @param mapReader Map reader on the detailed .img file.
*/
private void readPoints(MapReader mapReader) {
Area bounds = overviewSource.getBounds();
Zoom[] levels = mapReader.getLevels();
for (int l = 1; l < levels.length; l++) {
int min = levels[l].getLevel();
int res = levels[l].getResolution();
List<Point> pointList = mapReader.pointsForLevel(min, MapReader.WITH_EXT_TYPE_DATA);
for (Point point : pointList) {
if (log.isDebugEnabled())
log.debug("got point", point);
if (bounds.contains(point.getLocation()) == false) {
if (log.isDebugEnabled())
log.debug(point, "dropped, is outside of tile boundary");
continue;
}
MapPoint mp = new MapPoint();
mp.setType(point.getType());
if (point.getLabel() != null) {
mp.setName(point.getLabel().getText());
}
mp.setMaxResolution(res);
mp.setMinResolution(res);
mp.setLocation(point.getLocation());
overviewSource.addPoint(mp);
}
}
}
Aggregations