private JSONArray getLayerInfo()
        {
            JSONArray layersArray = new JSONArray();

            for (int i = 0; i < this.layerInfos.Count; i++)
            {
                IMapLayerInfo layerInfo = layerInfos.get_Element(i);
                JSONObject    jo        = new JSONObject();
                jo.AddString("name", layerInfo.Name);
                jo.AddLong("id", layerInfo.ID);
                jo.AddString("description", layerInfo.Description);
                layersArray.AddJSONObject(jo);
            }

            return(layersArray);
        }
Пример #2
0
        private byte[] LayersResHandler(NameValueCollection boundVariables, string outputFormat, string requestProperties, out string responseProperties)
        {
            responseProperties = "{\"Content-Type\" : \"application/json\"}";
            String aoLayerType = "";

            if (this.layerType.Equals("feature"))
            {
                aoLayerType = "Feature Layer";
            }
            else if (this.layerType.Equals("raster"))
            {
                aoLayerType = "Raster Layer";
            }
            else if (this.layerType.Equals("dataset"))
            {
                aoLayerType = "Network Dataset Layer";
            }
            else
            {
                throw new Exception("Propety layerType has invalid value. Acceptable values are \"feature\", \"raster\", and \"dataset\".");
            }

            JSONArray layersArray = new JSONArray();

            for (int i = 0; i < this.layerInfos.Count; i++)
            {
                IMapLayerInfo layerInfo = layerInfos.get_Element(i);
                String        lType     = layerInfo.Type;
                if (lType.Equals(aoLayerType))
                {
                    JSONObject jo = new JSONObject();
                    jo.AddString("name", layerInfo.Name);
                    jo.AddLong("id", layerInfo.ID);
                    jo.AddString("description", layerInfo.Description);
                    layersArray.AddJSONObject(jo);
                }
            }

            JSONObject result = new JSONObject();

            result.AddJSONArray("Layers", layersArray);
            return(Encoding.UTF8.GetBytes(result.ToJSONString(null)));
        }
Пример #3
0
        private byte[] LayersResHandler(NameValueCollection boundVariables, string outputFormat, string requestProperties, out string responseProperties)
        {
            responseProperties = "{\"Content-Type\" : \"application/json\"}";

            JSONArray layersArray = new JSONArray();

            for (int i = 0; i < this.layerInfos.Count; i++)
            {
                IMapLayerInfo layerInfo = layerInfos.get_Element(i);
                JSONObject    jo        = new JSONObject();
                jo.AddString("name", layerInfo.Name);
                jo.AddLong("id", layerInfo.ID);
                jo.AddString("type", layerInfo.Type);
                jo.AddString("description", layerInfo.Description);

                layersArray.AddJSONObject(jo);
            }

            JSONObject result = new JSONObject();

            result.AddJSONArray("layers", layersArray);
            return(Encoding.UTF8.GetBytes(result.ToJSONString(null)));
        }
        private JSONArray getLayerInfo()
        {
            JSONArray layersArray = new JSONArray();
            for (int i = 0; i < this.layerInfos.Count; i++)
            {
                IMapLayerInfo layerInfo = layerInfos.get_Element(i);
                JSONObject jo = new JSONObject();
                jo.AddString("name", layerInfo.Name);
                jo.AddLong("id", layerInfo.ID);
                jo.AddString("description", layerInfo.Description);
                layersArray.AddJSONObject(jo);
            }

            return layersArray;
        }
        private byte[] LayersResHandler(NameValueCollection boundVariables, string outputFormat, string requestProperties, out string responseProperties)
        {
            responseProperties = "{\"Content-Type\" : \"application/json\"}";
            String aoLayerType = "";
            if (this.layerType.Equals("feature"))
            {
                aoLayerType = "Feature Layer";
            }
            else if (this.layerType.Equals("raster"))
            {
                aoLayerType = "Raster Layer";
            }
            else if (this.layerType.Equals("dataset"))
            {
                aoLayerType = "Network Dataset Layer";
            }
            else
            {
                throw new Exception("Propety layerType has invalid value. Acceptable values are \"feature\", \"raster\", and \"dataset\".");
            }

            JSONArray layersArray = new JSONArray();
            for (int i = 0; i < this.layerInfos.Count; i++)
            {
                IMapLayerInfo layerInfo = layerInfos.get_Element(i);
                String lType = layerInfo.Type;
                if (lType.Equals(aoLayerType))
                {
                    JSONObject jo = new JSONObject();
                    jo.AddString("name", layerInfo.Name);
                    jo.AddLong("id", layerInfo.ID);
                    jo.AddString("description", layerInfo.Description);
                    layersArray.AddJSONObject(jo);
                }
            }

            JSONObject result = new JSONObject();
            result.AddJSONArray("Layers", layersArray);
            return Encoding.UTF8.GetBytes(result.ToJSONString(null));
        }
Пример #6
0
        private byte[] LayersResHandler(NameValueCollection boundVariables, string outputFormat, string requestProperties, out string responseProperties)
        {
            responseProperties = "{\"Content-Type\" : \"application/json\"}";

            JSONArray layersArray = new JSONArray();
            for (int i = 0; i < this.layerInfos.Count; i++)
            {
                IMapLayerInfo layerInfo = layerInfos.get_Element(i);
                JSONObject jo = new JSONObject();
                jo.AddString("name", layerInfo.Name);
                jo.AddLong("id", layerInfo.ID);
                jo.AddBoolean("addlayer", false);
                jo.AddString("description", layerInfo.Description);
              
                layersArray.AddJSONObject(jo);
            }

            JSONObject result = new JSONObject();
            result.AddJSONArray("layers", layersArray);
            return Encoding.UTF8.GetBytes(result.ToJSONString(null));
        }
        private byte[] QueryByExtentHandler(NameValueCollection boundVariables,
                                            JsonObject operationInput,
                                            string outputFormat,
                                            string requestProperties,
                                            out string responseProperties)
        {
            responseProperties = null;

            if (networkDataset == null)
            {
                throw new NullReferenceException("Could not access the network dataset.");
            }

            if (!operationInput.TryGetString("Extent", out var envelopeString))
            {
                throw new ArgumentNullException("Extent is invalid.");
            }
            var coords    = envelopeString.Split(';');
            var minCoords = coords[0].Split(',');
            var maxCoords = coords[1].Split(',');

            double.TryParse(minCoords[0].Trim(), out var minX);
            double.TryParse(minCoords[1].Trim(), out var minY);
            double.TryParse(maxCoords[0].Trim(), out var maxX);
            double.TryParse(maxCoords[0].Trim(), out var maxY);

            // Find features in envelope
            IEnvelope env = new EnvelopeClass();

            env.PutCoords(minX, minY, maxX, maxY);
            ISpatialFilter spatialFilter = new SpatialFilter();

            spatialFilter.Geometry   = env;
            spatialFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;

            // Add selected features OID into LongArray
            ILongArray     oIDs    = new LongArray();
            IFeatureCursor fCursor = streetFC.Search(spatialFilter, true);
            IFeature       feature = fCursor.NextFeature();

            while (feature != null)
            {
                oIDs.Add(feature.OID);
                feature = fCursor.NextFeature();
            }

            // Get the network edges corresponding to the streets and write out information about them

            INetworkQuery    networkQuery = networkDataset as INetworkQuery;
            INetworkJunction fromJunction =
                networkQuery.CreateNetworkElement(esriNetworkElementType.esriNETJunction) as INetworkJunction;
            INetworkJunction toJunction =
                networkQuery.CreateNetworkElement(esriNetworkElementType.esriNETJunction) as INetworkJunction;

            IEnumNetworkElement networkElements = networkQuery.ElementsByOIDs[streetsSourceID, oIDs];
            INetworkElement     networkElement  = networkElements.Next();
            JSONObject          result          = new JSONObject();
            JSONArray           elementArray    = new JSONArray();
            INetworkEdge        networkEdge;

            while (networkElement != null)
            {
                JSONObject jo = new JSONObject();
                networkEdge = networkElement as INetworkEdge;
                networkEdge.QueryJunctions(fromJunction, toJunction);
                double travelTime = (double)networkEdge.AttributeValue[travelTimeAttributeID];
                jo.AddLong("EdgeID", networkEdge.EID);
                jo.AddLong("FromJunctionID", fromJunction.EID);
                jo.AddLong("ToJunctionID", toJunction.EID);
                jo.AddDoubleEx(costAttributeName, travelTime, 4);
                elementArray.AddJSONObject(jo);
                networkElement = networkElements.Next();
            }
            result.AddJSONArray("NetworkElements", elementArray);

            return(Encoding.UTF8.GetBytes(result.ToJSONString(null)));
        }