Beispiel #1
0
  Object parsePrimem(final Element parent, final Unit angularUnit) throws ParseException {
    final Element element = parent.pullElement("PRIMEM");
    final String name = element.pullString("name");
    final double longitude = element.pullDouble("longitude");
    final Map<String, ?> properties = parseAuthority(element, name);
    element.close();

    return null;
  }
Beispiel #2
0
  Projection parseProjection(Element e) throws ParseException {
    Element p = e.pullElement("PROJECTION");
    String name = p.pullString("name");

    Projection proj = new Registry().getProjection(name);
    if (proj == null) {
      throw new IllegalArgumentException("Unsupported projection: " + name);
    }

    return proj;
  }
Beispiel #3
0
  Ellipsoid parseSpheroid(final Element parent) throws ParseException {
    Element element = parent.pullElement("SPHEROID");
    String name = element.pullString("name");
    double semiMajorAxis = element.pullDouble("semiMajorAxis");
    double inverseFlattening = element.pullDouble("inverseFlattening");
    Map<String, ?> properties = parseAuthority(element, name);
    element.close();
    if (inverseFlattening == 0) {
      // Inverse flattening null is an OGC convention for a sphere.
      inverseFlattening = Double.POSITIVE_INFINITY;
    }

    return new Ellipsoid(name, semiMajorAxis, 0, inverseFlattening, name);
  }
Beispiel #4
0
  Unit parseUnit(final Element parent, final Unit unit) throws ParseException {
    final Element element = parent.pullElement("UNIT");
    final String name = element.pullString("name");
    final double factor = element.pullDouble("factor");

    final Map<String, ?> properties = parseAuthority(element, name);
    element.close();

    if (name != null) {
      Unit u = Units.findUnits(name.toLowerCase());
      if (u != null) {
        return u;
      }
    }

    return (factor != 1) ? times(unit, factor) : unit;
  }
Beispiel #5
0
  Datum parseDatum(final Element parent, final Object meridian) throws ParseException {
    Element element = parent.pullElement("DATUM");
    String name = element.pullString("name");
    Ellipsoid ellipsoid = parseSpheroid(element);

    double[] toWGS84 = parseToWGS84(element); // Optional; may be
    // null.
    Map<String, Object> properties = parseAuthority(element, name);
    if (true /*ALLOW_ORACLE_SYNTAX*/ && (toWGS84 == null) && (element.peek() instanceof Number)) {
      toWGS84 = new double[7];
      toWGS84[0] = element.pullDouble("dx");
      toWGS84[1] = element.pullDouble("dy");
      toWGS84[2] = element.pullDouble("dz");
      toWGS84[3] = element.pullDouble("ex");
      toWGS84[4] = element.pullDouble("ey");
      toWGS84[5] = element.pullDouble("ez");
      toWGS84[6] = element.pullDouble("ppm");
    }
    element.close();

    return new Datum(name, toWGS84, ellipsoid, name);
  }
Beispiel #6
0
  CoordinateReferenceSystem parseProjCS(Element e) throws ParseException {
    String authCode = parseAuthCode(e);
    if (authCode != null) {
      CoordinateReferenceSystem crs = Proj.crs(authCode);
      if (crs != null) {
        return crs;
      }
    }

    // parse manually
    String name = e.pullString("name");
    CoordinateReferenceSystem geo = parseGeoGCS(e.pullElement("GEOGCS"));

    Projection proj = parseProjection(e);
    String[] params = parseParameters(e);

    // TODO:
    /*
    Unit unit = parseUnit(e, Units.METRES);
    parseAxis(e);
    parseAxis(e);
    */
    return new CoordinateReferenceSystem(name, params, geo.getDatum(), proj);
  }