use of com.revolsys.collection.map.MapEx in project com.revolsys.open by revolsys.
the class TileInfo method setProperties.
@Override
public void setProperties(final Map<String, ? extends Object> values) {
super.setProperties(values);
final MapEx origin = (MapEx) values.get("origin");
if (origin == null) {
this.originX = Double.NaN;
this.originY = Double.NaN;
} else {
this.originX = origin.getDouble("x");
this.originY = origin.getDouble("y");
}
this.geometryFactory = ArcGisResponse.newGeometryFactory((MapEx) values, "spatialReference");
this.levelOfDetails = ArcGisResponse.newList(LevelOfDetail.class, (MapEx) values, "lods");
}
use of com.revolsys.collection.map.MapEx in project com.revolsys.open by revolsys.
the class FeatureSource method refreshDo.
@Override
protected void refreshDo() {
final MapEx properties = new LinkedHashMapEx();
final String resourceId = getResourceId();
properties.put("RESOURCEID", resourceId);
final MapGuideWebService webService = getWebService();
final MapEx schemaResource = webService.getJsonResponse("DESCRIBEFEATURESCHEMA", properties);
final MapEx schema = schemaResource.getValue("xs:schema");
if (schema != null) {
final Map<String, String> prefixByUri = new HashMap<>();
for (final String name : schema.keySet()) {
if (name.startsWith("@xmlns:")) {
final String namespaceUri = getString(schema, name);
final String prefix = name.substring(7);
prefixByUri.put(namespaceUri, prefix);
}
}
final String targetNamespace = getString(schema, "@targetNamespace");
final String prefix = prefixByUri.get(targetNamespace);
final Map<String, MapEx> complexTypeDefinitions = new HashMap<>();
for (final MapEx complexType : schema.getValue("xs:complexType", Collections.<MapEx>emptyList())) {
String name = getString(complexType, "@name");
if (prefix != null) {
name = prefix + ":" + name;
}
complexTypeDefinitions.put(name, complexType);
}
final List<FeatureLayer> layers = new ArrayList<>();
final Map<String, FeatureLayer> layerByName = new HashMap<>();
for (final MapEx element : schema.getValue("xs:element", Collections.<MapEx>emptyList())) {
final String name = getString(element, "@name");
final String type = getString(element, "@type");
final MapEx complexType = complexTypeDefinitions.get(type);
final FeatureLayer layer = newLayer(name, element, complexType);
if (layer != null) {
layers.add(layer);
layerByName.put(name.toLowerCase(), layer);
}
this.layers = layers;
this.layerByName = layerByName;
}
}
}
use of com.revolsys.collection.map.MapEx in project com.revolsys.open by revolsys.
the class FeatureSource method newLayer.
private FeatureLayer newLayer(final String name, final MapEx element, final MapEx complexType) {
if (!"true".equals(getString(complexType, "@abstract"))) {
final PathName pathName = getPathName();
final PathName layerPathName = pathName.newChild(name);
final RecordDefinitionImpl recordDefinition = new RecordDefinitionImpl(layerPathName);
GeometryFactory geometryFactory = GeometryFactory.DEFAULT_3D;
final MapEx complexContent = getValue(complexType, "xs:complexContent");
final MapEx extension = getValue(complexContent, "xs:extension");
if ("gml:AbstractFeatureType".equals(getString(extension, "@base"))) {
final MapEx sequence = getValue(extension, "xs:sequence");
final List<MapEx> elements = sequence.getValue("xs:element");
for (final MapEx fieldElement : elements) {
final String fieldName = getString(fieldElement, "@name");
final boolean required = !"0".equals(getString(fieldElement, "@minOccurs"));
DataType dataType = DataTypes.STRING;
final MapEx simpleFieldType = getValue(fieldElement, "xs:simpleType");
if (simpleFieldType == null) {
final String fieldType = getString(fieldElement, "@type");
if ("gml:AbstractGeometryType".equals(fieldType)) {
final String geometryTypes = getString(fieldElement, "@fdo:geometryTypes");
for (final String geometryType : geometryTypes.split(" ")) {
final DataType geometryDataType = DataTypes.getDataType(geometryType);
if (geometryDataType != DataTypes.OBJECT) {
if (dataType == DataTypes.STRING) {
dataType = geometryDataType;
} else if (dataType == DataTypes.GEOMETRY) {
} else if (geometryDataType == DataTypes.GEOMETRY) {
dataType = DataTypes.GEOMETRY;
} else if (geometryDataType == DataTypes.GEOMETRY_COLLECTION) {
dataType = DataTypes.GEOMETRY;
} else if (dataType.equals(DataTypes.POINT)) {
if (geometryDataType.equals(DataTypes.POINT)) {
} else if (geometryDataType.equals(DataTypes.MULTI_POINT)) {
dataType = DataTypes.MULTI_POINT;
} else {
dataType = DataTypes.GEOMETRY;
}
} else if (dataType.equals(DataTypes.MULTI_POINT)) {
if (geometryDataType.equals(DataTypes.POINT)) {
} else if (geometryDataType.equals(DataTypes.MULTI_POINT)) {
} else {
dataType = DataTypes.GEOMETRY;
}
} else if (dataType.equals(DataTypes.LINE_STRING)) {
if (geometryDataType.equals(DataTypes.LINE_STRING)) {
} else if (geometryDataType.equals(DataTypes.MULTI_LINE_STRING)) {
dataType = DataTypes.MULTI_LINE_STRING;
} else {
dataType = DataTypes.GEOMETRY;
}
} else if (dataType.equals(DataTypes.MULTI_LINE_STRING)) {
if (geometryDataType.equals(DataTypes.LINE_STRING)) {
} else if (geometryDataType.equals(DataTypes.MULTI_LINE_STRING)) {
} else {
dataType = DataTypes.GEOMETRY;
}
} else if (dataType.equals(DataTypes.POLYGON)) {
if (geometryDataType.equals(DataTypes.POLYGON)) {
} else if (geometryDataType.equals(DataTypes.MULTI_POLYGON)) {
dataType = DataTypes.MULTI_POLYGON;
} else {
dataType = DataTypes.GEOMETRY;
}
} else if (dataType.equals(DataTypes.MULTI_POLYGON)) {
if (geometryDataType.equals(DataTypes.POLYGON)) {
} else if (geometryDataType.equals(DataTypes.MULTI_POLYGON)) {
} else {
dataType = DataTypes.GEOMETRY;
}
}
}
}
if (dataType == DataTypes.STRING) {
dataType = DataTypes.GEOMETRY;
}
int axisCount = 2;
if ("true".equals(getString(fieldElement, "@fdo:hasMeasure"))) {
axisCount = 4;
} else if ("true".equals(getString(fieldElement, "@fdo:hasElevation"))) {
axisCount = 3;
}
final String srsName = getString(fieldElement, "@fdo:srsName");
if (Property.hasValue(srsName)) {
final Integer coordinateSystemId = Maps.getInteger(this.coordinateSystemIdBySrsName, srsName);
if (coordinateSystemId == null) {
try {
final Map<String, Object> csParameters = Collections.singletonMap("CSCODE", srsName);
final MapGuideWebService webService = getWebService();
final Resource wktResource = webService.getResource("CS.CONVERTCOORDINATESYSTEMCODETOWKT", null, csParameters);
final String wkt = wktResource.contentsAsString();
geometryFactory = GeometryFactory.floating(wkt, axisCount);
} catch (final Throwable e) {
}
} else {
geometryFactory = GeometryFactory.floating(coordinateSystemId, axisCount);
}
}
}
} else {
final MapEx restriction = getValue(simpleFieldType, "xs:restriction");
if (restriction != null) {
final String fieldBase = getString(restriction, "@base");
dataType = DataTypes.getDataType(fieldBase.replace("xs:", ""));
}
}
if (dataType != null) {
recordDefinition.addField(fieldName, dataType, required);
}
}
recordDefinition.setGeometryFactory(geometryFactory);
final FeatureLayer layer = new FeatureLayer(this, recordDefinition);
return layer;
}
}
return null;
}
use of com.revolsys.collection.map.MapEx in project com.revolsys.open by revolsys.
the class ArcGisResponse method refreshDo.
protected void refreshDo() {
final UrlResource serviceUrl = getServiceUrl();
final Resource resource;
if (isUseProxy()) {
final String url = serviceUrl.getUriString() + "%3ff%3djson";
final String username = serviceUrl.getUsername();
final String password = serviceUrl.getPassword();
resource = new UrlResource(url, username, password);
} else {
resource = serviceUrl.newUrlResource(Collections.singletonMap("f", "json"));
}
final MapEx newProperties = Json.toMap(resource);
initialize(newProperties);
}
use of com.revolsys.collection.map.MapEx in project com.revolsys.open by revolsys.
the class ArcGisResponse method getProperties.
@Override
public synchronized MapEx getProperties() {
final MapEx properties = super.getProperties();
if (Property.isEmpty(properties)) {
properties.put("initializing", true);
properties.put("initializing", false);
}
return properties;
}
Aggregations