I am trying to use openstreetmap osmosis to read a pbf file of an airport and extract features like gates and runways.
I am using code similar to: http://www.javaoptimum.com/how-to-read-osm-pbf-files-programmatically-java/
When the code encounters a Node
instance, it returns reasonable values from getLatitude and getLongitude...
However when the code encounters a Way
instance the coordinates appear to be zero. Here is the code that I am using:
Sink sinkImplementation = new Sink() {
public void process(EntityContainer entityContainer) {
Entity entity = entityContainer.getEntity();
entity.getTags().forEach((tag) -> {
if ("aeroway".equals(tag.getKey())) {
if (entity instanceof Node) {
if ("holding_position".equals(tag.getValue())) {
installPointHook(airportIcaoCode, entity, tag);
} else if ("gate".equals(tag.getValue())) {
installPointHook(airportIcaoCode, entity, tag);
} else {
LOGGER.info("Ignoring unrecognized tag value " + tag.getValue());
}
} else if (entity instanceof Way) {
Way way = (Way)entity;
if ("runway".equals(tag.getValue())) {
way.getWayNodes().forEach((it) -> System.out.println(it + " : " + it.getLatitude()+","+it.getLongitude()));
} else if ("taxiway".equals(tag.getValue())) {
way.getWayNodes().forEach((it) -> System.out.println(it + " : " + it.getLatitude()+","+it.getLongitude()));
} else if ("apron".equals(tag.getValue())) {
way.getWayNodes().forEach((it) -> System.out.println(it + " : " + it.getLatitude()+","+it.getLongitude()));
} else if ("hangar".equals(tag.getValue())) {
way.getWayNodes().forEach((it) -> System.out.println(it + " : " + it.getLatitude()+","+it.getLongitude()));
} else {
LOGGER.info("Ignoring unrecognized tag value " + tag.getValue());
}
} else if (entity instanceof Relation) {
LOGGER.info("Ignoring unrecognized tag value " + tag.getValue());
}
}
});
}
public void initialize(Map<String, Object> arg0) {
}
public void complete() {
}
@Override
public void close() {
}
};
Is there some other processing I need to do in order to get the coordinates for Way
s?