persolijn

an efficient router for busses
Log | Files | Refs

HeaderBBox.java (922B)


      1 package osm.message;
      2 
      3 import java.util.Iterator;
      4 
      5 import protobuf.Message;
      6 import protobuf.ProtobufReader;
      7 
      8 // required sint64 left = 1;
      9 // required sint64 right = 2;
     10 // required sint64 top = 3;
     11 // required sint64 bottom = 4;
     12 public class HeaderBBox implements Message<double[]> {
     13     public static final double NANO = 1e-9;
     14 
     15     @Override
     16     public double[] parse(Iterator<ProtobufReader> iter) {
     17         double[] bbox = new double[4];
     18 
     19         while (iter.hasNext()) {
     20             ProtobufReader message = iter.next();
     21             switch (message.tag()) {
     22                 case 1 -> bbox[0] = NANO * message.svarint64();
     23                 case 2 -> bbox[1] = NANO * message.svarint64();
     24                 case 3 -> bbox[2] = NANO * message.svarint64();
     25                 case 4 -> bbox[3] = NANO * message.svarint64();
     26                 default -> message.throwUnexpected();
     27             }
     28         }
     29 
     30         return bbox;
     31     }
     32 }