use of org.locationtech.geogig.storage.FieldType in project GeoGig by boundlessgeo.
the class FormatCommonV1 method readFeature.
public static RevFeature readFeature(ObjectId id, DataInput in) throws IOException {
final int count = in.readInt();
final ImmutableList.Builder<Optional<Object>> builder = ImmutableList.builder();
for (int i = 0; i < count; i++) {
final byte fieldTag = in.readByte();
final FieldType fieldType = FieldType.valueOf(fieldTag);
Object value = DataStreamValueSerializerV1.read(fieldType, in);
builder.add(Optional.fromNullable(value));
}
return new RevFeatureImpl(id, builder.build());
}
use of org.locationtech.geogig.storage.FieldType in project GeoGig by boundlessgeo.
the class FormatCommonV2 method readAttributeType.
private static AttributeType readAttributeType(DataInput in, FeatureTypeFactory typeFactory) throws IOException {
final Name name = readName(in);
final byte typeTag = in.readByte();
final FieldType type = FieldType.valueOf(typeTag);
if (Geometry.class.isAssignableFrom(type.getBinding())) {
// as opposed to a raw WKT string
final boolean isCRSCode = in.readBoolean();
final String crsText = in.readUTF();
final CoordinateReferenceSystem crs;
try {
if (isCRSCode) {
if ("urn:ogc:def:crs:EPSG::0".equals(crsText)) {
crs = null;
} else {
boolean forceLongitudeFirst = crsText.startsWith("EPSG:");
crs = CRS.decode(crsText, forceLongitudeFirst);
}
} else {
crs = CRS.parseWKT(crsText);
}
} catch (FactoryException e) {
throw new RuntimeException(e);
}
return typeFactory.createGeometryType(name, type.getBinding(), crs, false, false, Collections.<Filter>emptyList(), null, null);
} else {
return typeFactory.createAttributeType(name, type.getBinding(), false, false, Collections.<Filter>emptyList(), null, null);
}
}
use of org.locationtech.geogig.storage.FieldType in project GeoGig by boundlessgeo.
the class FormatCommonV2 method writeFeature.
public static void writeFeature(RevFeature feature, DataOutput data) throws IOException {
ImmutableList<Optional<Object>> values = feature.getValues();
writeUnsignedVarInt(values.size(), data);
for (Optional<Object> field : values) {
FieldType type = FieldType.forValue(field);
data.writeByte(type.getTag());
if (type != FieldType.NULL) {
DataStreamValueSerializerV2.write(field, data);
}
}
}
use of org.locationtech.geogig.storage.FieldType in project GeoGig by boundlessgeo.
the class FormatCommonV2 method readFeature.
public static RevFeature readFeature(ObjectId id, DataInput in) throws IOException {
final int count = readUnsignedVarInt(in);
final ImmutableList.Builder<Optional<Object>> builder = ImmutableList.builder();
for (int i = 0; i < count; i++) {
final byte fieldTag = in.readByte();
final FieldType fieldType = FieldType.valueOf(fieldTag);
Object value = DataStreamValueSerializerV2.read(fieldType, in);
builder.add(Optional.fromNullable(value));
}
return new RevFeatureImpl(id, builder.build());
}
Aggregations