use of uk.me.parabola.imgfmt.app.trergn.Subdivision in project mkgmap by openstreetmap.
the class Map method topLevelSubdivision.
/**
* Create the top level division. It must be empty afaik and cover
* the whole area of the map.
*
* @param area The whole map area.
* @param zoom The zoom level that you want the top level to be
* at. Its going to be at least level 1.
* @return The top level division.
*/
public Subdivision topLevelSubdivision(Area area, Zoom zoom) {
// May not always be necessary/desired
zoom.setInherited(true);
InternalFiles ifiles = this;
Subdivision sub = Subdivision.topLevelSubdivision(ifiles, area, zoom);
rgnFile.startDivision(sub);
return sub;
}
use of uk.me.parabola.imgfmt.app.trergn.Subdivision in project mkgmap by openstreetmap.
the class MapReader method pointsForLevel.
/**
* Get a list of all the points for a given level.
* @param level The level, lower numbers are the most detailed.
*/
public List<Point> pointsForLevel(int level, boolean withExtType) {
List<Point> points = new ArrayList<Point>();
Subdivision[] subdivisions = treFile.subdivForLevel(level);
for (Subdivision sd : subdivisions) {
List<Point> subdivPoints = rgnFile.pointsForSubdiv(sd, withExtType);
points.addAll(subdivPoints);
}
return points;
}
use of uk.me.parabola.imgfmt.app.trergn.Subdivision in project mkgmap by openstreetmap.
the class MapBuilder method makeMapAreas.
/**
* Drive the map generation by stepping through the levels, generating the
* subdivisions for the level and filling in the map elements that should
* go into the area.
*
* This is fairly complex: you need to divide into subdivisions depending on
* their size and the number of elements that will be contained.
*
* @param map The map.
* @param src The data for the map.
*/
private void makeMapAreas(Map map, LoadableMapDataSource src) {
// The top level has to cover the whole map without subdividing, so
// do a special check to make sure.
LevelInfo[] levels = null;
if (src instanceof OverviewMapDataSource) {
mergeLines = true;
prepShapesForMerge(src.getShapes());
mergeShapes = true;
levels = src.mapLevels();
} else {
if (OverviewBuilder.isOverviewImg(map.getFilename())) {
levels = src.overviewMapLevels();
} else {
levels = src.mapLevels();
}
}
if (levels == null) {
throw new ExitException("no info about levels available.");
}
LevelInfo levelInfo = levels[0];
// If there is already a top level zoom, then we shouldn't add our own
Subdivision topdiv;
if (levelInfo.isTop()) {
// There is already a top level definition. So use the values from it and
// then remove it from the levels definition.
levels = Arrays.copyOfRange(levels, 1, levels.length);
Zoom zoom = map.createZoom(levelInfo.getLevel(), levelInfo.getBits());
topdiv = makeTopArea(src, map, zoom);
} else {
// We have to automatically create the definition for the top zoom level.
int maxBits = getMaxBits(src);
// decrease it so that it is less.
if (levelInfo.getBits() <= maxBits)
maxBits = levelInfo.getBits() - 1;
// Create the empty top level
Zoom zoom = map.createZoom(levelInfo.getLevel() + 1, maxBits);
topdiv = makeTopArea(src, map, zoom);
}
// We start with one map data source.
List<SourceSubdiv> srcList = Collections.singletonList(new SourceSubdiv(src, topdiv));
// Now the levels filled with features.
for (LevelInfo linfo : levels) {
List<SourceSubdiv> nextList = new ArrayList<>();
Zoom zoom = map.createZoom(linfo.getLevel(), linfo.getBits());
for (SourceSubdiv srcDivPair : srcList) {
MapSplitter splitter = new MapSplitter(srcDivPair.getSource(), zoom);
MapArea[] areas = splitter.split(orderByDecreasingArea);
log.info("Map region", srcDivPair.getSource().getBounds(), "split into", areas.length, "areas at resolution", zoom.getResolution());
for (MapArea area : areas) {
Subdivision parent = srcDivPair.getSubdiv();
Subdivision div = makeSubdivision(map, parent, area, zoom);
if (log.isDebugEnabled())
log.debug("ADD parent-subdiv", parent, srcDivPair.getSource(), ", z=", zoom, " new=", div);
nextList.add(new SourceSubdiv(area, div));
}
if (nextList.size() > 0) {
Subdivision lastdiv = nextList.get(nextList.size() - 1).getSubdiv();
lastdiv.setLast(true);
}
}
srcList = nextList;
}
}
Aggregations