예제 #1
0
 String parseAuthCode(Element e) throws ParseException {
   Element a = e.pullOptionalElement("AUTHORITY");
   if (a != null) {
     return a.pullString("name") + ":" + a.pullString("code");
   }
   return null;
 }
예제 #2
0
  Map<String, Object> parseAuthority(final Element parent, final String name)
      throws ParseException {

    final boolean isRoot = parent.isRoot();
    final Element element = parent.pullOptionalElement("AUTHORITY");
    Map<String, Object> properties;
    if (element == null) {
      if (isRoot) {
        properties = new HashMap<String, Object>(4);
        properties.put(NAME_KEY, name);
      } else {
        properties = Collections.singletonMap(NAME_KEY, (Object) name);
      }
    } else {
      final String auth = element.pullString("name");
      // the code can be annotation marked but could be a number to
      String code = element.pullOptionalString("code");
      if (code == null) {
        int codeNumber = element.pullInteger("code");
        code = String.valueOf(codeNumber);
      }
      element.close();

      // final Citation authority = Citations.fromName(auth);
      properties = new HashMap<String, Object>(4);
      properties.put(NAME_KEY, auth + ":" + name);
      properties.put(IDENTIFIERS_KEY, auth + ":" + code);
    }
    if (isRoot) {
      // properties = alterProperties(properties);
    }
    return properties;
  }
예제 #3
0
  String[] parseParameters(Element e) throws ParseException {
    Element p = null;
    List<String> params = new ArrayList<String>();
    while ((p = e.pullOptionalElement("PARAMETER")) != null) {
      String key = p.pullString("name");
      Double val = p.pullDouble("value");

      Param param = Param.valueOf(key);
      if (param == null) {
        throw new IllegalArgumentException("Unsupported projection parameter: " + key);
      }

      params.add(String.format("%s=%f", param.proj4, val));
    }

    return params.toArray(new String[params.size()]);
  }
예제 #4
0
  double[] parseToWGS84(final Element parent) throws ParseException {
    final Element element = parent.pullOptionalElement("TOWGS84");
    if (element == null) {
      return null;
    }

    double dx = element.pullDouble("dx");
    double dy = element.pullDouble("dy");
    double dz = element.pullDouble("dz");

    try {
      if (element.peek() != null) {
        double ex = element.pullDouble("ex");
        double ey = element.pullDouble("ey");
        double ez = element.pullDouble("ez");
        double ppm = element.pullDouble("ppm");
        return new double[] {dx, dy, dz, ex, ey, ez, ppm};
      } else {
        return new double[] {dx, dy, dz};
      }
    } finally {
      element.close();
    }
  }
예제 #5
0
 void parseAxis(Element e) throws ParseException {
   e.pullOptionalElement("AXIS");
 }