本文整理汇总了Java中org.mapsforge.map.writer.model.TDNode类的典型用法代码示例。如果您正苦于以下问题:Java TDNode类的具体用法?Java TDNode怎么用?Java TDNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TDNode类属于org.mapsforge.map.writer.model包,在下文中一共展示了TDNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addPOI
import org.mapsforge.map.writer.model.TDNode; //导入依赖的package包/类
protected void addPOI(TDNode poi) {
if (!poi.isPOI()) {
return;
}
byte minZoomLevel = poi.getZoomAppear();
for (int i = 0; i < this.zoomIntervalConfiguration.getNumberOfZoomIntervals(); i++) {
// is POI seen in a zoom interval?
if (minZoomLevel <= this.zoomIntervalConfiguration.getMaxZoom(i)) {
long tileCoordinateX = MercatorProjection.longitudeToTileX(
CoordinatesUtil.microdegreesToDegrees(poi.getLongitude()),
this.zoomIntervalConfiguration.getBaseZoom(i));
long tileCoordinateY = MercatorProjection.latitudeToTileY(
CoordinatesUtil.microdegreesToDegrees(poi.getLatitude()),
this.zoomIntervalConfiguration.getBaseZoom(i));
TileData tileData = getTileImpl(i, (int) tileCoordinateX, (int) tileCoordinateY);
if (tileData != null) {
tileData.addPOI(poi);
countPoiTags(poi);
}
}
}
}
示例2: getWayBoundingBox
import org.mapsforge.map.writer.model.TDNode; //导入依赖的package包/类
private static TileCoordinate[] getWayBoundingBox(final TDWay way, byte zoomlevel, int enlargementInPixel) {
double maxx = Double.NEGATIVE_INFINITY, maxy = Double.NEGATIVE_INFINITY, minx = Double.POSITIVE_INFINITY, miny = Double.POSITIVE_INFINITY;
for (TDNode coordinate : way.getWayNodes()) {
maxy = Math.max(maxy, CoordinatesUtil.microdegreesToDegrees(coordinate.getLatitude()));
miny = Math.min(miny, CoordinatesUtil.microdegreesToDegrees(coordinate.getLatitude()));
maxx = Math.max(maxx, CoordinatesUtil.microdegreesToDegrees(coordinate.getLongitude()));
minx = Math.min(minx, CoordinatesUtil.microdegreesToDegrees(coordinate.getLongitude()));
}
double[] epsilonsTopLeft = computeTileEnlargement(maxy, enlargementInPixel);
double[] epsilonsBottomRight = computeTileEnlargement(miny, enlargementInPixel);
TileCoordinate[] bbox = new TileCoordinate[2];
bbox[0] = new TileCoordinate((int) MercatorProjection.longitudeToTileX(minx - epsilonsTopLeft[1], zoomlevel),
(int) MercatorProjection.latitudeToTileY(maxy + epsilonsTopLeft[0], zoomlevel), zoomlevel);
bbox[1] = new TileCoordinate(
(int) MercatorProjection.longitudeToTileX(maxx + epsilonsBottomRight[1], zoomlevel),
(int) MercatorProjection.latitudeToTileY(miny - epsilonsBottomRight[0], zoomlevel), zoomlevel);
return bbox;
}
示例3: store
import org.mapsforge.map.writer.model.TDNode; //导入依赖的package包/类
public void store(TDNode node, boolean commit) {
String command = String.format(STATMENT_INSERT_NODE_TEMPLATE, node.getId(), node.getLatitude(), node.getLongitude());
try {
execute(command, commit);
} catch (SQLException e) {
LOGGER.error("Store Node: " + node.getId() + " / " + e.getLocalizedMessage().substring(0, 39) + "...");
}
}
示例4: getNode
import org.mapsforge.map.writer.model.TDNode; //导入依赖的package包/类
@Override public TDNode getNode(long osmId) {
try {
ResultSet rs = getDBConnection().createStatement().executeQuery("SELECT Lat, Lon FROM node WHERE osmid='" + osmId + "' ");
while (rs.next()) {
return new TDNode(osmId, rs.getInt("lat"), rs.getInt("Lon"), (short) 0, (byte) 5, null, null);
}
// no entry found return 0
return null;
} catch (SQLException e) {
return null;
}
}
示例5: storeNode
import org.mapsforge.map.writer.model.TDNode; //导入依赖的package包/类
@Override public void storeNode(TDNode node, boolean commit) {
long osmId = node.getId();
int latitude = node.getLatitude();
int longitude = node.getLongitude();
String command = String.format(STATMENT_INSERT_NODE_TEMPLATE, osmId, latitude, longitude);
try {
execute(command, commit);
} catch (SQLException e) {
LOGGER.error("Store Node: " + osmId + " / " + e.getLocalizedMessage().substring(0, 39) + "...");
}
}
示例6: getNode
import org.mapsforge.map.writer.model.TDNode; //导入依赖的package包/类
@Override
public TDNode getNode() throws IOException {
while (nodeStack.isEmpty()) {
try {
Thread.sleep(1);
} catch (InterruptedException e) {
LOGGER.error("InterruptException with wait of get Node");
}
}
return nodeStack.get();
}
示例7: addNode
import org.mapsforge.map.writer.model.TDNode; //导入依赖的package包/类
void addNode(TDNode node) {
while (nodeStack.isFull()) {
try {
Thread.sleep(1);
} catch (InterruptedException e) {
LOGGER.error("InterruptException with wait of add Node");
}
}
nodeStack.add(node);
}
示例8: storeNode
import org.mapsforge.map.writer.model.TDNode; //导入依赖的package包/类
public void storeNode(TDNode node, boolean commit) throws IOException {
count++;
byte[] bytes = SERIALIZE_DESIRALIZE.getBytes(node);
tblOsmId.storeOsmId(bytes); //store OsmId
tblNodeLatLon.storeLatLon(bytes); // store Latitude and Longitude
long pointer = tblNodeData.storeData(bytes); // store data
int length = bytes.length - 11;
tblNodeIndex.storePointerAndLength(pointer, length);
if (commit)
commit();
}
示例9: parseNodeFromReadBuffer
import org.mapsforge.map.writer.model.TDNode; //导入依赖的package包/类
private static TDNode parseNodeFromReadBuffer(IByteArray array, int start, int end, boolean withTags, List<String> preferredLanguages) {
TDNode node = null;
parsedNodes++;
if (withTags)
parsedNodesWithTags++;
//parse ID
long id = getValueOfProperty_ID(array, start, end);
//parse latitude
int lat = getValueOfProperty_LAT_LON(array, PROPERTY_LATITUDE, start, end);
//parse longitude
int lon = getValueOfProperty_LAT_LON(array, PROPERTY_LONGITUDE, start, end);
if (withTags) {
// parse Tags
LMTag[] tags = getTags(array, start, end);
try {
LMUtils.SpecialTagExtractionResult esf = LMUtils.extractSpecialFields(tags, preferredLanguages);
short[] knownWayTags = LMUtils.extractKnownPOITags(tags);
return new TDNode(id, lat, lon, esf.getElevation(), esf.getLayer(), esf.getHousenumber(), esf.getName(), knownWayTags);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
return new TDNode(id, lat, lon, (short) 0, (byte) 5, null, null);
}
示例10: create
import org.mapsforge.map.writer.model.TDNode; //导入依赖的package包/类
@Test
public void create() throws Exception {
// delete DB before test
DeleteDbFiles.execute(CONSTANTS.RESOURCE, dbName, true);
DataBase H2DB = new DataBase(new File(dbPath).getAbsolutePath(), user, pw);
TDNode node1 = new TDNode(1, 1, 1, (short) 1, (byte) 1, null, null);
TDNode node2 = new TDNode(2, 1, 2, (short) 1, (byte) 1, null, null);
TDNode node3 = new TDNode(3, 2, 2, (short) 1, (byte) 1, null, null);
TDNode node4 = new TDNode(4, 3, 3, (short) 1, (byte) 1, null, null);
TDNode node5 = new TDNode(5, 4, 4, (short) 1, (byte) 1, null, null);
H2DB.store(node1, false);
H2DB.store(node2, false);
H2DB.store(node3, false);
H2DB.store(node4, false);
H2DB.store(node5, true);
IntBoundingBox bb = new IntBoundingBox(1, 1, 2, 2);
IElementStreamReader reader = H2DB.getStreamReader(bb);
TDNode[] nodes = new TDNode[5];
int idx = 0;
while (reader.hasNextNode()) {
nodes[idx++] = reader.getNode();
}
assertEquals(nodes[0], node1);
assertEquals(nodes[1], node2);
assertEquals(nodes[2], node3);
assertEquals(nodes[3], null);
assertEquals(nodes[4], null);
}
示例11: countPoiTags
import org.mapsforge.map.writer.model.TDNode; //导入依赖的package包/类
protected void countPoiTags(TDNode poi) {
if (poi == null || poi.getTags() == null) {
return;
}
for (short tag : poi.getTags()) {
this.histogramPoiTags.adjustOrPutValue(tag, 1, 1);
}
}
示例12: getNode
import org.mapsforge.map.writer.model.TDNode; //导入依赖的package包/类
@Override
public TDNode getNode(long id) {
if (this.nodeIndexReader == null) {
throw new IllegalStateException("node store not accessible, call complete() first");
}
try {
return TDNode.fromNode(this.nodeIndexReader.get(id), this.preferredLanguage);
} catch (NoSuchIndexElementException e) {
LOGGER.finer("node cannot be found in index: " + id);
return null;
}
}
示例13: fromHDTileData
import org.mapsforge.map.writer.model.TDNode; //导入依赖的package包/类
private RAMTileData fromHDTileData(HDTileData hdt) {
final RAMTileData td = new RAMTileData();
TLongIterator it = hdt.getPois().iterator();
while (it.hasNext()) {
td.addPOI(TDNode.fromNode(this.nodeIndexReader.get(it.next()), this.preferredLanguage));
}
it = hdt.getWays().iterator();
while (it.hasNext()) {
TDWay way = null;
long id = it.next();
try {
way = TDWay.fromWay(this.wayIndexReader.get(id), this, this.preferredLanguage);
td.addWay(way);
} catch (NoSuchIndexElementException e) {
// is it a virtual way?
way = this.virtualWays.get(id);
if (way != null) {
td.addWay(way);
} else {
LOGGER.finer("referenced way non-existing" + id);
}
}
if (way != null) {
if (this.outerToInnerMapping.contains(way.getId())) {
way.setShape(TDWay.MULTI_POLYGON);
}
List<TDRelation> associatedRelations = this.additionalRelationTags.get(id);
if (associatedRelations != null) {
for (TDRelation tileDataRelation : associatedRelations) {
way.mergeRelationInformation(tileDataRelation);
}
}
}
}
return td;
}
示例14: infoBytePoiLayerAndTagAmount
import org.mapsforge.map.writer.model.TDNode; //导入依赖的package包/类
static byte infoBytePoiLayerAndTagAmount(TDNode node) {
byte layer = node.getLayer();
// make sure layer is in [0,10]
layer = layer < 0 ? 0 : layer > 10 ? 10 : layer;
short tagAmount = node.getTags() == null ? 0 : (short) node.getTags().length;
return (byte) (layer << BYTES_INT | tagAmount);
}
示例15: RAMTileBasedDataProcessor
import org.mapsforge.map.writer.model.TDNode; //导入依赖的package包/类
private RAMTileBasedDataProcessor(MapWriterConfiguration configuration) {
super(configuration);
this.nodes = new TLongObjectHashMap<TDNode>();
this.ways = new TLongObjectHashMap<TDWay>();
this.multipolygons = new TLongObjectHashMap<TDRelation>();
this.tileData = new RAMTileData[this.zoomIntervalConfiguration.getNumberOfZoomIntervals()][][];
// compute number of tiles needed on each base zoom level
for (int i = 0; i < this.zoomIntervalConfiguration.getNumberOfZoomIntervals(); i++) {
this.tileData[i] = new RAMTileData[this.tileGridLayouts[i].getAmountTilesHorizontal()][this.tileGridLayouts[i]
.getAmountTilesVertical()];
}
}