本文整理汇总了Java中de.topobyte.osm4j.core.model.iface.OsmNode类的典型用法代码示例。如果您正苦于以下问题:Java OsmNode类的具体用法?Java OsmNode怎么用?Java OsmNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OsmNode类属于de.topobyte.osm4j.core.model.iface包,在下文中一共展示了OsmNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: build
import de.topobyte.osm4j.core.model.iface.OsmNode; //导入依赖的package包/类
/**
* Build a MultiPolygon from a Relation.
*
* @param relation a relation to construct the region for.
* @return the constructed MultiPolygon.
* @throws EntityNotFoundException when a required entity cannot be obtained.
*/
public RegionBuilderResult build(OsmRelation relation,
OsmEntityProvider resolver) throws EntityNotFoundException {
EntityNotFoundStrategy enfs = Util.strategy(this.missingEntitiesStrategy,
this.log, this.logLevel);
logger.debug("building region id:" + relation.getId());
Set<OsmRelation> relations = new HashSet<>();
MultiSet<OsmWay> ways = new HashMultiSet<>();
EntityFinder finder = EntityFinders.create(resolver, enfs);
relations.add(relation);
finder.findMemberRelations(relation, relations);
finder.findMemberWays(relations, ways);
Set<OsmNode> nodes = new HashSet<>();
if (this.includePuntal) {
finder.findMemberNodes(relations, nodes);
}
return this.build(ways, resolver, nodes);
}
示例2: toCoordinateSequence
import de.topobyte.osm4j.core.model.iface.OsmNode; //导入依赖的package包/类
private CoordinateSequence toCoordinateSequence(OsmEntityProvider resolver)
throws EntityNotFoundException {
CoordinateSequenceFactory csf = factory.getCoordinateSequenceFactory();
int len = this.getLength();
CoordinateSequence points = csf.create(len, 2);
int n = 0;
for (int i = 0; i < this.segments.size(); i++) {
WaySegment segment = this.segments.get(i);
OsmWay way = segment.getWay();
for (int k = 0; k < way.getNumberOfNodes(); k++) {
if (k > 0 || i == 0) {
OsmNode node = resolver.getNode(segment.getNodeId(k));
points.setOrdinate(n, 0, node.getLongitude());
points.setOrdinate(n, 1, node.getLatitude());
n++;
}
}
}
return points;
}
示例3: build
import de.topobyte.osm4j.core.model.iface.OsmNode; //导入依赖的package包/类
public LineworkBuilderResult build(OsmRelation relation,
OsmEntityProvider provider) throws EntityNotFoundException {
EntityNotFoundStrategy enfs = Util.strategy(this.missingEntitiesStrategy,
this.log, this.logLevel);
EntityFinder finder = EntityFinders.create(provider, enfs);
Set<OsmNode> nodes = new HashSet<>();
Set<OsmWay> ways = new HashSet<>();
try {
finder.findMemberNodesAndWays(relation, nodes, ways);
} catch (EntityNotFoundException e) {
switch (this.missingEntitiesStrategy) {
default:
case THROW_EXCEPTION:
throw (e);
case BUILD_EMPTY:
return new LineworkBuilderResult();
case BUILD_PARTIAL:
// Can't happen, because we're using the IGNORE strategy in this
// case
break;
}
}
return this.build(nodes, ways, provider);
}
示例4: handle
import de.topobyte.osm4j.core.model.iface.OsmNode; //导入依赖的package包/类
@Override
public void handle(OsmNode node) {
synchronized (this.mutex) {
while (true) {
if (this.state == State.PUSH) {
this.beyondBounds = true;
this.list.add(new EntityContainer(EntityType.Node, node));
if (this.list.size() == LIMIT) {
this.state = State.READ;
this.mutex.notify();
}
return;
}
try {
this.mutex.wait();
} catch (InterruptedException e) {
// interrupted
}
}
}
}
示例5: write
import de.topobyte.osm4j.core.model.iface.OsmNode; //导入依赖的package包/类
@Override
public void write(OsmNode node) {
this.out.print(" <node id=\"" + node.getId() + "\"");
this.out.print(" lat=\"" + this.f.format(node.getLatitude()) + "\"");
this.out.print(" lon=\"" + this.f.format(node.getLongitude()) + "\"");
if (this.printMetadata) {
OsmMetadata metadata = node.getMetadata();
this.printMetadata(metadata);
}
if (node.getNumberOfTags() == 0) {
this.out.println("/>");
} else {
this.out.println(">");
this.printTags(node);
this.out.println(" </node>");
}
}
示例6: addMember
import de.topobyte.osm4j.core.model.iface.OsmNode; //导入依赖的package包/类
protected void addMember(OsmRelationMember member,
Collection<OsmNode> outNodes, Collection<OsmWay> outWays,
Collection<OsmRelation> outRelations,
OsmEntityProvider entityProvider) throws EntityNotFoundException {
if (member.getType() == EntityType.Node) {
if (outNodes != null) {
outNodes.add(entityProvider.getNode(member.getId()));
}
} else if (member.getType() == EntityType.Way) {
if (outWays != null) {
outWays.add(entityProvider.getWay(member.getId()));
}
} else if (member.getType() == EntityType.Relation) {
if (outRelations != null) {
outRelations.add(entityProvider.getRelation(member.getId()));
}
}
}
示例7: next
import de.topobyte.osm4j.core.model.iface.OsmNode; //导入依赖的package包/类
@Override
public EntityContainer next() {
List<OsmNode> nodes = this.data.getNodes();
List<OsmWay> ways = this.data.getWays();
List<OsmRelation> relations = this.data.getRelations();
if (this.index < nodes.size()) {
return new EntityContainer(EntityType.Node, nodes.get(this.index++));
}
int wayIndex = this.index - nodes.size();
if (wayIndex < ways.size()) {
this.index++;
return new EntityContainer(EntityType.Way, ways.get(wayIndex));
}
int relationIndex = wayIndex - ways.size();
if (relationIndex < relations.size()) {
this.index++;
return new EntityContainer(EntityType.Relation,
relations.get(relationIndex));
}
throw new NoSuchElementException();
}
示例8: read
import de.topobyte.osm4j.core.model.iface.OsmNode; //导入依赖的package包/类
@Override
public void read() throws OsmInputException {
try {
if (this.data.hasBounds()) {
this.handler.handle(this.data.getBounds());
}
for (OsmNode node : this.data.getNodes()) {
this.handler.handle(node);
}
for (OsmWay way : this.data.getWays()) {
this.handler.handle(way);
}
for (OsmRelation relation : this.data.getRelations()) {
this.handler.handle(relation);
}
this.handler.complete();
} catch (IOException e) {
throw new OsmInputException(e);
}
}
示例9: write
import de.topobyte.osm4j.core.model.iface.OsmNode; //导入依赖的package包/类
public static void write(OsmIterator iterator, OsmOutputStream output)
throws IOException {
if (iterator.hasBounds()) {
output.write(iterator.getBounds());
}
while (iterator.hasNext()) {
EntityContainer container = iterator.next();
switch (container.getType()) {
case Node:
output.write((OsmNode) container.getEntity());
break;
case Way:
output.write((OsmWay) container.getEntity());
break;
case Relation:
output.write((OsmRelation) container.getEntity());
break;
}
}
output.complete();
}
示例10: handle
import de.topobyte.osm4j.core.model.iface.OsmNode; //导入依赖的package包/类
@Override
public void handle(OsmNode node) throws IOException {
numNodes++;
persistence.writeNode((Node) node);
ver.put(node.getId(), node.getLatitude());
ver.put(node.getId(), node.getLongitude());
}
示例11: checkRings
import de.topobyte.osm4j.core.model.iface.OsmNode; //导入依赖的package包/类
/**
* For each ring in this collection of rings, check whether it is closed. If
* not, print some status information.
*
* @param missingEntitiesStrategy
* @return whether all rings are closed.
*/
public static void checkRings(Collection<ChainOfWays> rings,
OsmEntityProvider resolver,
MissingEntitiesStrategy missingEntitiesStrategy)
throws EntityNotFoundException {
for (ChainOfWays ring : rings) {
if (ring.isClosed()) {
continue;
}
List<WaySegment> segments = ring.getSegments();
int len = 0;
for (WaySegment rs : segments) {
len += rs.getWay().getNumberOfNodes();
}
WaySegment seg0 = segments.get(0);
WaySegment segN = segments.get(segments.size() - 1);
long nodeId1 = seg0.getNodeId(0);
long nodeIdN = segN.getNodeId(segN.getNumberOfNodes() - 1);
try {
OsmNode node1 = resolver.getNode(nodeId1);
OsmNode nodeN = resolver.getNode(nodeIdN);
logger.debug("we have an unclosed ring of size " + len);
logger.debug(String.format("start/end: %f,%f %f,%f",
node1.getLongitude(), node1.getLatitude(),
nodeN.getLongitude(), nodeN.getLatitude()));
} catch (EntityNotFoundException e) {
switch (missingEntitiesStrategy) {
case BUILD_PARTIAL:
continue;
default:
case BUILD_EMPTY:
case THROW_EXCEPTION:
throw (e);
}
}
}
}
示例12: buildSplitIfNodeMissing
import de.topobyte.osm4j.core.model.iface.OsmNode; //导入依赖的package包/类
public WayBuilderResult buildSplitIfNodeMissing(OsmWay way,
OsmEntityProvider resolver) {
// Test if the way is closed, i.e. first node id == last node id
boolean closed = OsmModelUtil.isClosed(way);
// Remember if the first node is missing, so that we can handle closed
// ways appropriately
boolean firstMissing = false;
CoordinateSequencesBuilder builder = new CoordinateSequencesBuilder();
builder.beginNewSequence();
for (int i = 0; i < way.getNumberOfNodes(); i++) {
OsmNode node;
try {
node = resolver.getNode(way.getNodeId(i));
} catch (EntityNotFoundException e) {
if (this.log) {
this.logMissingNode(way.getNodeId(i));
}
if (i == 0) {
firstMissing = true;
}
builder.beginNewSequence();
continue;
}
builder.add(new Coordinate(node.getLongitude(), node.getLatitude()));
}
builder.finishSequence();
return builder.createWayBuilderResult(this.factory, this.includePuntal, closed,
firstMissing);
}
示例13: box
import de.topobyte.osm4j.core.model.iface.OsmNode; //导入依赖的package包/类
public static Envelope box(Collection<OsmNode> nodes) {
Envelope env = new Envelope();
for (OsmNode node : nodes) {
env.expandToInclude(node.getLongitude(), node.getLatitude());
}
return env;
}
示例14: findWayNodes
import de.topobyte.osm4j.core.model.iface.OsmNode; //导入依赖的package包/类
@Override
public void findWayNodes(Collection<OsmWay> ways,
Collection<OsmNode> outNodes) throws EntityNotFoundException {
for (OsmWay way : ways) {
this.findWayNodes(way, outNodes);
}
}
示例15: findMemberNodes
import de.topobyte.osm4j.core.model.iface.OsmNode; //导入依赖的package包/类
@Override
public void findMemberNodes(Collection<OsmRelation> relations,
Set<OsmNode> outNodes) throws EntityNotFoundException {
for (OsmRelation relation : relations) {
this.findMemberNodes(relation, outNodes);
}
}