1

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!

0

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();
    }

}
  • Thx! Works great if I use the vertex file – TimVG Feb 27 '13 at 20:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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