Search in sources :

Example 1 with NamedCoordinateReferenceSystem

use of com.mongodb.client.model.geojson.NamedCoordinateReferenceSystem in project mongo-java-driver by mongodb.

the class GeometryDecoderHelper method decodeCoordinateReferenceSystem.

@Nullable
static CoordinateReferenceSystem decodeCoordinateReferenceSystem(final BsonReader reader) {
    String crsName = null;
    validateIsDocument(reader);
    reader.readStartDocument();
    while (reader.readBsonType() != BsonType.END_OF_DOCUMENT) {
        String name = reader.readName();
        if (name.equals("type")) {
            String type = reader.readString();
            if (!type.equals("name")) {
                throw new CodecConfigurationException(format("Unsupported CoordinateReferenceSystem '%s'.", type));
            }
        } else if (name.equals("properties")) {
            crsName = decodeCoordinateReferenceSystemProperties(reader);
        } else {
            throw new CodecConfigurationException(format("Found invalid key '%s' in the CoordinateReferenceSystem.", name));
        }
    }
    reader.readEndDocument();
    return crsName != null ? new NamedCoordinateReferenceSystem(crsName) : null;
}
Also used : NamedCoordinateReferenceSystem(com.mongodb.client.model.geojson.NamedCoordinateReferenceSystem) CodecConfigurationException(org.bson.codecs.configuration.CodecConfigurationException) LineString(com.mongodb.client.model.geojson.LineString) MultiLineString(com.mongodb.client.model.geojson.MultiLineString) Nullable(com.mongodb.lang.Nullable)

Aggregations

LineString (com.mongodb.client.model.geojson.LineString)1 MultiLineString (com.mongodb.client.model.geojson.MultiLineString)1 NamedCoordinateReferenceSystem (com.mongodb.client.model.geojson.NamedCoordinateReferenceSystem)1 Nullable (com.mongodb.lang.Nullable)1 CodecConfigurationException (org.bson.codecs.configuration.CodecConfigurationException)1