Package ca.carleton.gcrc.geom.wkt

Examples of ca.carleton.gcrc.geom.wkt.WktParser


  }

  public void outputExport(Writer writer) throws Exception {
    JSONWriter jsonWriter = new JSONWriter(writer);
    GeoJsonGeometryWriter geoWriter = new GeoJsonGeometryWriter();
    WktParser wktParser = new WktParser();
 
    jsonWriter.object();
   
    jsonWriter.key("type");
    jsonWriter.value("FeatureCollection");

    jsonWriter.key("features");
    jsonWriter.array();
   
    while( retrieval.hasNext() ){
      Document doc = retrieval.getNext();
      if( null != doc
       && docFilter.accepts(doc) ) {
        JSONObject jsonDoc = doc.getJSONObject();
       
        String schemaName = jsonDoc.optString("nunaliit_schema");
        if( null != schemaName ) {
          SchemaExportInfo exportInfo = schemaCache.getExportInfo(schemaName);
          if( null != exportInfo ){
            jsonWriter.object();
           
            jsonWriter.key("type");
            jsonWriter.value("Feature");

            jsonWriter.key("id");
            jsonWriter.value(doc.getId());
           
            jsonWriter.key("properties");
            jsonWriter.object();
           
            for(SchemaExportProperty exportProperty : exportInfo.getProperties()){
              Object value = exportProperty.select(jsonDoc);
              if( null != value ) {
                jsonWriter.key(exportProperty.getLabel());
                jsonWriter.value(value);
              }
            }
           
            jsonWriter.endObject(); // end properties
           
            if( JSONSupport.containsKey(jsonDoc, "nunaliit_geom") ) {
              JSONObject jsonGeom = jsonDoc.getJSONObject("nunaliit_geom");
              String wkt = jsonGeom.optString("wkt", null);
              if( null != wkt ){
                Geometry geometry = wktParser.parseWkt(wkt);
                jsonWriter.key("geometry");
                geoWriter.writeGeometry(jsonWriter, geometry);
              }
            }
           
View Full Code Here


  }

  public void outputExport(Writer writer) throws Exception {
    JSONWriter jsonWriter = new JSONWriter(writer);
    GeoJsonGeometryWriter geoWriter = new GeoJsonGeometryWriter();
    WktParser wktParser = new WktParser();
 
    jsonWriter.object();
   
    jsonWriter.key("type");
    jsonWriter.value("FeatureCollection");

    jsonWriter.key("features");
    jsonWriter.array();
   
    while( retrieval.hasNext() ){
      Document doc = retrieval.getNext();
      if( null != doc
       && docFilter.accepts(doc) ) {
        JSONObject jsonDoc = doc.getJSONObject();
       
        String schemaName = jsonDoc.optString("nunaliit_schema");
        if( null != schemaName ) {
          boolean containsGeometry = JSONSupport.containsKey(jsonDoc, "nunaliit_geom");
          SchemaExportInfo exportInfo = schemaCache.getExportInfo(schemaName);
         
          if( null != exportInfo || containsGeometry ){
            jsonWriter.object();
           
            jsonWriter.key("type");
            jsonWriter.value("Feature");

            jsonWriter.key("id");
            jsonWriter.value(doc.getId());
           
            jsonWriter.key("properties");
            jsonWriter.object();
           
            if( null != exportInfo ){
              for(SchemaExportProperty exportProperty : exportInfo.getProperties()){
                Object value = exportProperty.select(jsonDoc);
                if( null != value ) {
                  jsonWriter.key(exportProperty.getLabel());
                  jsonWriter.value(value);
                }
              }
            }
           
            jsonWriter.endObject(); // end properties
           
            if( containsGeometry ) {
              JSONObject jsonGeom = jsonDoc.getJSONObject("nunaliit_geom");
              String wkt = jsonGeom.optString("wkt", null);
              if( null != wkt ){
                Geometry geometry = wktParser.parseWkt(wkt);
                jsonWriter.key("geometry");
                geoWriter.writeGeometry(jsonWriter, geometry);
              }
            }
           
View Full Code Here

TOP

Related Classes of ca.carleton.gcrc.geom.wkt.WktParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.