예제 #1
0
 protected Coordinate decodeCoordinate(JsonNode node) throws GeoJSONException {
   if (!node.isArray()) {
     throw new GeoJSONException("expected array");
   }
   final int dim = node.size();
   if (dim < DIM_2D) {
     throw new GeoJSONException("coordinates may have at least 2 dimensions");
   }
   if (dim > DIM_3D) {
     throw new GeoJSONException("coordinates may have at most 3 dimensions");
   }
   final Coordinate coordinate = new Coordinate();
   for (int i = 0; i < dim; ++i) {
     if (node.get(i).isNumber()) {
       coordinate.setOrdinate(i, node.get(i).doubleValue());
     } else {
       throw new GeoJSONException("coordinate index " + i + " has to be a number");
     }
   }
   return coordinate;
 }