Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

For a software component were using we need to provide 2 input files. One with a list of nodes (nodeId, lat, lon) and one with ways (fromNodeId, toNodeId, oneway, maxSpeed, lenght).

To create these 2 files I created a custom postprocessor class, you can find the code here: https://gist.github.com/anonymous/5047904

To get the Nodes I read the "tn_raw.2po" file, for the ways the "sw_all.2po" file. This works great, but now my node output files contains all osm nodes. What I would like, is that the file only contains the nodes used in the ways file.

Is it possible to only output the used nodes in a file?

Thanks!

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Use the sv_all.2po and sw_all.2po instead.

The corresponding classes are:

  • Vertex
  • SegmentedWay

Here is a sample of how to loop over the Vertices:

File inFile = new File("sv_all.2po");
InStream is = new InStreamDisk(inFile);
byte type = is.readByte(); // We know what's in there

Vertex vertex = new Vertex();
while (!is.isEof()) {
  vertex.readFromStream(is);
  System.out.println(vertex);
}

is.close();

Every *.2po-file follows the same loop pattern. Here is the original code for the cmd=d option.

public class Debug {

    public static void dump2poFile(Config config) throws Exception {

        InStream inStream = new InStreamDisk(config.getFiles().get(0));
        byte varType = inStream.readByte();
        Var var = VarTypeDesk.create(varType);
        int i = 0;
        while (!inStream.isEof()) {
            System.out.println("[" + (i++) + "] " +  var.readFromStream(inStream));
        }
        inStream.close();
    }

}
share|improve this answer
    
Thx! Works great if I use the vertex file –  TimVG Feb 27 '13 at 20:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.