Search in sources :

Example 36 with MapEx

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");
}
Also used : MapEx(com.revolsys.collection.map.MapEx)

Example 37 with MapEx

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;
        }
    }
}
Also used : LinkedHashMapEx(com.revolsys.collection.map.LinkedHashMapEx) MapEx(com.revolsys.collection.map.MapEx) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) LinkedHashMapEx(com.revolsys.collection.map.LinkedHashMapEx)

Example 38 with MapEx

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;
}
Also used : GeometryFactory(com.revolsys.geometry.model.GeometryFactory) LinkedHashMapEx(com.revolsys.collection.map.LinkedHashMapEx) MapEx(com.revolsys.collection.map.MapEx) WebServiceResource(com.revolsys.webservice.WebServiceResource) Resource(com.revolsys.spring.resource.Resource) RecordDefinitionImpl(com.revolsys.record.schema.RecordDefinitionImpl) DataType(com.revolsys.datatype.DataType) PathName(com.revolsys.io.PathName)

Example 39 with MapEx

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);
}
Also used : UrlResource(com.revolsys.spring.resource.UrlResource) MapEx(com.revolsys.collection.map.MapEx) UrlResource(com.revolsys.spring.resource.UrlResource) WebServiceResource(com.revolsys.webservice.WebServiceResource) Resource(com.revolsys.spring.resource.Resource)

Example 40 with MapEx

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;
}
Also used : MapEx(com.revolsys.collection.map.MapEx)

Aggregations

MapEx (com.revolsys.collection.map.MapEx)144 LinkedHashMapEx (com.revolsys.collection.map.LinkedHashMapEx)48 ArrayList (java.util.ArrayList)17 Resource (com.revolsys.spring.resource.Resource)9 GeometryFactory (com.revolsys.geometry.model.GeometryFactory)7 Map (java.util.Map)7 HashMap (java.util.HashMap)6 PathName (com.revolsys.io.PathName)5 UrlResource (com.revolsys.spring.resource.UrlResource)5 DataType (com.revolsys.datatype.DataType)4 FieldDefinition (com.revolsys.record.schema.FieldDefinition)4 PathResource (com.revolsys.spring.resource.PathResource)4 Color (java.awt.Color)4 LinkedHashMap (java.util.LinkedHashMap)4 List (java.util.List)4 TreeMap (java.util.TreeMap)4 NamedLinkedHashMapEx (com.revolsys.collection.map.NamedLinkedHashMapEx)3 Geometry (com.revolsys.geometry.model.Geometry)3 LineString (com.revolsys.geometry.model.LineString)3 Record (com.revolsys.record.Record)3