use of org.apache.solr.response.transform.WriteableGeoJSON in project lucene-solr by apache.
the class GeoJSONWriter method writeGeo.
protected void writeGeo(Object geo) throws IOException {
Shape shape = null;
String str = null;
if (geo instanceof Shape) {
shape = (Shape) geo;
} else if (geo instanceof IndexableField) {
str = ((IndexableField) geo).stringValue();
} else if (geo instanceof WriteableGeoJSON) {
shape = ((WriteableGeoJSON) geo).shape;
} else {
str = geo.toString();
}
if (str != null) {
// Assume it is well formed JSON
if (str.startsWith("{") && str.endsWith("}")) {
writer.write(str);
return;
}
if (formats == null) {
// *stored* values for the field look like JSON until we actually try to read them
throw new SolrException(ErrorCode.BAD_REQUEST, "GeoJSON unable to write field: '&" + GeoJSONResponseWriter.FIELD + "=" + geofield + "' (" + str + ")");
}
shape = formats.read(str);
}
if (geowriter == null) {
throw new SolrException(ErrorCode.BAD_REQUEST, "GeoJSON unable to write field: '&" + GeoJSONResponseWriter.FIELD + "=" + geofield + "'");
}
if (shape != null) {
geowriter.write(writer, shape);
}
}
Aggregations