use of com.runwaysdk.dataaccess.ProgrammingErrorException in project geoprism-registry by terraframe.
the class VectorTileBuilder method writeVectorLayer.
public VectorTile.Tile.Layer writeVectorLayer(String layerName, Envelope bounds, ResultSet resultSet) throws IOException {
try {
List<Geometry> geometries = new LinkedList<Geometry>();
while (resultSet.next()) {
String label = resultSet.getString("default_locale");
Map<String, String> data = new TreeMap<String, String>();
data.put(GeoEntity.OID, resultSet.getString("oid"));
data.put(DefaultAttribute.CODE.getName(), resultSet.getString("code"));
data.put(DefaultAttribute.UID.getName(), resultSet.getString("uid"));
data.put(GeoEntity.DISPLAYLABEL, label);
for (Locale locale : locales) {
try {
data.put(GeoEntity.DISPLAYLABEL + "_" + locale.toString().toLowerCase(), resultSet.getString(locale.toString()));
} catch (PSQLException e) {
// Ignore: The column doesn't exist because the list was created
// before the locale was installed
}
}
JtsGeometry geom = (JtsGeometry) resultSet.getObject(GeoserverFacade.GEOM_COLUMN);
if (geom != null) {
Geometry geometry = geom.getGeometry();
geometry.setUserData(data);
geometries.add(geometry);
}
}
GeometryFactory geomFactory = new GeometryFactory();
IGeometryFilter acceptAllGeomFilter = geometry -> true;
MvtLayerParams layerParams = new MvtLayerParams();
TileGeomResult tileGeom = JtsAdapter.createTileGeom(geometries, bounds, geomFactory, layerParams, acceptAllGeomFilter);
// Create MVT layer
final MvtLayerProps layerProps = new MvtLayerProps();
final IUserDataConverter ignoreUserData = new UserDataConverter();
// MVT tile geometry to MVT features
final List<VectorTile.Tile.Feature> features = JtsAdapter.toFeatures(tileGeom.mvtGeoms, layerProps, ignoreUserData);
final VectorTile.Tile.Layer.Builder layerBuilder = MvtLayerBuild.newLayerBuilder(layerName, layerParams);
layerBuilder.addAllFeatures(features);
MvtLayerBuild.writeProps(layerBuilder, layerProps);
// Build MVT layer
return layerBuilder.build();
} catch (SQLException e) {
throw new ProgrammingErrorException(e);
}
}
use of com.runwaysdk.dataaccess.ProgrammingErrorException in project geoprism-registry by terraframe.
the class DHIS2TestService method metadataGet.
@Override
public <T> MetadataGetResponse<T> metadataGet(Class<?> dhis2Type, List<NameValuePair> params) throws InvalidLoginException, HTTPException {
String objectNamePlural = DHIS2Objects.getPluralObjectNameFromClass(dhis2Type);
try {
if (objectNamePlural.equals(DHIS2Objects.OPTIONS)) {
InputStream data = Thread.currentThread().getContextClassLoader().getResourceAsStream("dhis2/2.31.9/options.json");
String resp = IOUtils.toString(data, "UTF-8");
return new MetadataGetResponse<T>(resp, 200, objectNamePlural, dhis2Type);
} else if (objectNamePlural.equals(DHIS2Objects.OPTIONSETS)) {
InputStream data = Thread.currentThread().getContextClassLoader().getResourceAsStream("dhis2/2.31.9/optionsets.json");
String resp = IOUtils.toString(data, "UTF-8");
return new MetadataGetResponse<T>(resp, 200, objectNamePlural, dhis2Type);
} else if (objectNamePlural.equals(DHIS2Objects.ATTRIBUTES)) {
InputStream data = Thread.currentThread().getContextClassLoader().getResourceAsStream("dhis2/2.31.9/attributes.json");
String resp = IOUtils.toString(data, "UTF-8");
return new MetadataGetResponse<T>(resp, 200, objectNamePlural, dhis2Type);
} else if (objectNamePlural.equals(DHIS2Objects.ORGANISATION_UNIT_GROUPS)) {
InputStream data = Thread.currentThread().getContextClassLoader().getResourceAsStream("dhis2/default/organisationUnitGroups.json");
String resp = IOUtils.toString(data, "UTF-8");
return new MetadataGetResponse<T>(resp, 200, objectNamePlural, dhis2Type);
} else {
JsonObject jo = new JsonObject();
JsonObject system = new JsonObject();
system.addProperty("id", "eed3d451-4ff5-4193-b951-ffcc68954299");
system.addProperty("rev", "86fbbf7");
system.addProperty("version", "2.31.9");
system.addProperty("date", "2020-07-17T23:03:46.853");
jo.add("system", system);
jo.add(objectNamePlural, new JsonArray());
return new MetadataGetResponse<T>(jo.toString(), 200, objectNamePlural, dhis2Type);
}
} catch (IOException e) {
throw new ProgrammingErrorException(e);
}
}
Aggregations