use of net.geoprism.registry.io.LocationBuilder in project geoprism-registry by terraframe.
the class GeoObjectImporter method parsePostalCode.
private ServerGeoObjectIF parsePostalCode(FeatureRow feature) {
LocationBuilder builder = PostalCodeFactory.get(this.configuration.getType());
Location location = builder.build(this.configuration.getFunction(GeoObject.CODE));
ShapefileFunction function = location.getFunction();
String code = (String) function.getValue(feature);
if (code != null) {
// Search
ServerGeoObjectQuery query = new ServerGeoObjectService().createQuery(location.getType(), this.configuration.getStartDate());
query.setRestriction(new ServerCodeRestriction(code));
// Assert.assertNull(query.getSingleResult());
ServerGeoObjectIF result = query.getSingleResult();
if (result != null) {
return result;
} else {
PostalCodeLocationException e = new PostalCodeLocationException();
e.setCode(code);
e.setTypeLabel(location.getType().getLabel().getValue());
throw e;
}
}
return null;
}
use of net.geoprism.registry.io.LocationBuilder in project geoprism-registry by terraframe.
the class ShapefileServiceTest method testGetAttributeInformationPostalCode.
@Test
@Request
public void testGetAttributeInformationPostalCode() {
InputStream istream = this.getClass().getResourceAsStream("/cb_2017_us_state_500k.zip.test");
ServerGeoObjectType type = USATestData.STATE.getServerObject();
PostalCodeFactory.addPostalCode(type, new LocationBuilder() {
@Override
public Location build(ShapefileFunction function) {
return null;
}
});
Assert.assertNotNull(istream);
ShapefileService service = new ShapefileService();
JSONObject result = service.getShapefileConfiguration(testData.clientRequest.getSessionId(), USATestData.STATE.getCode(), null, null, "cb_2017_us_state_500k.zip", istream, ImportStrategy.NEW_AND_UPDATE, false);
Assert.assertTrue(result.getBoolean(GeoObjectImportConfiguration.HAS_POSTAL_CODE));
}
Aggregations