use of org.opengis.feature.type.Name in project GeoGig by boundlessgeo.
the class FormatCommonV1 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
final boolean isCRSCode = in.readBoolean();
// WKT string
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.opengis.feature.type.Name 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.opengis.feature.type.Name in project GeoGig by boundlessgeo.
the class WorkingTreeTest method testDeleteCollection.
@Test
public void testDeleteCollection() throws Exception {
List<Feature> featureList = new LinkedList<Feature>();
featureList.add(points1);
featureList.add(points2);
featureList.add(points3);
workTree.insert(pointsName, featureList.iterator(), LISTENER, null, 3);
assertTrue(workTree.findUnstaged(appendChild(pointsName, idP1)).isPresent());
assertTrue(workTree.findUnstaged(appendChild(pointsName, idP2)).isPresent());
assertTrue(workTree.findUnstaged(appendChild(pointsName, idP3)).isPresent());
List<Feature> deleteFeatures = new LinkedList<Feature>();
deleteFeatures.add(points1);
deleteFeatures.add(points3);
Name typeName = points1.getName();
workTree.delete(typeName, null, deleteFeatures.iterator());
assertFalse(workTree.findUnstaged(appendChild(pointsName, idP1)).isPresent());
assertTrue(workTree.findUnstaged(appendChild(pointsName, idP2)).isPresent());
assertFalse(workTree.findUnstaged(appendChild(pointsName, idP3)).isPresent());
}
use of org.opengis.feature.type.Name in project GeoGig by boundlessgeo.
the class WorkingTreeTest method testHasRoot.
@Test
public void testHasRoot() throws Exception {
insert(points1);
Name typeName = points1.getName();
assertFalse(workTree.hasRoot(typeName));
}
use of org.opengis.feature.type.Name in project GeoGig by boundlessgeo.
the class WorkingTreeTest method testInsertSingle.
@Test
public void testInsertSingle() throws Exception {
Name name = points1.getType().getName();
String parentPath = name.getLocalPart();
Node ref = workTree.insert(parentPath, points1);
ObjectId objectId = ref.getObjectId();
assertEquals(objectId, workTree.findUnstaged(appendChild(pointsName, idP1)).get().getObjectId());
}
Aggregations