Search in sources :

Example 1 with GeoJsonReader

use of com.vividsolutions.jts.io.geojson.GeoJsonReader in project geoprism-registry by terraframe.

the class AbstractFhirResourceProcessor method getGeometry.

protected Geometry getGeometry(Location location, ServerGeoObjectType type) {
    Extension extension = location.getExtensionByUrl("http://hl7.org/fhir/StructureDefinition/location-boundary-geojson");
    if (extension != null) {
        Attachment value = (Attachment) extension.getValue();
        if (value.hasData()) {
            Decoder decoder = Base64.getDecoder();
            byte[] binary = decoder.decode(value.getDataElement().getValueAsString());
            String geojson = new String(binary);
            GeoJsonReader reader = new GeoJsonReader();
            try {
                return reader.read(geojson);
            } catch (ParseException e) {
                e.printStackTrace();
            }
        }
    }
    return null;
}
Also used : Extension(org.hl7.fhir.r4.model.Extension) GeoJsonReader(com.vividsolutions.jts.io.geojson.GeoJsonReader) Attachment(org.hl7.fhir.r4.model.Attachment) ParseException(com.vividsolutions.jts.io.ParseException) Decoder(java.util.Base64.Decoder)

Aggregations

ParseException (com.vividsolutions.jts.io.ParseException)1 GeoJsonReader (com.vividsolutions.jts.io.geojson.GeoJsonReader)1 Decoder (java.util.Base64.Decoder)1 Attachment (org.hl7.fhir.r4.model.Attachment)1 Extension (org.hl7.fhir.r4.model.Extension)1