Ejemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Geocrest.Model.ArcGIS.Geometry.Geometry"/> class.
 /// </summary>
 /// <param name="x">The X value.</param>
 /// <param name="y">The Y value.</param>
 /// <param name="sr">A well-known spatial reference ID.</param>
 public Geometry(double x, double y, WKID sr)
 {
     X = x;
     Y = y;
     SpatialReference = new SpatialReference(sr);
     GeometryType     = esriGeometryType.esriGeometryPoint;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Performs a query on the specified layer.
        /// </summary>
        /// <param name="layerId">The id of the layer to query.</param>
        /// <param name="query">A where clause for the query filter. Any legal SQL where clause operating on the fields in the layer is allowed.</param>
        /// <param name="outSR">The spatial reference of the returned geometry.</param>
        /// <param name="relationship">The spatial relationship to be applied on the input geometry while performing the query.</param>
        /// <param name="geometry">The geometry to apply as the spatial filter.</param>
        /// <param name="returnGeometry">If true, the resultset includes the geometry associated with each result.</param>
        /// <param name="objectIds">The object IDs of this layer / table to be queried.</param>
        /// <param name="outFields">The list of fields to be included in the returned resultset.</param>
        /// <param name="returnIdsOnly">If true, the response only includes an array of object IDs. Otherwise the response is a feature set.</param>
        /// <param name="returnCountOnly">If true, the response only includes the count (number of features / records) that would be returned by a query. Otherwise the response is a feature set.</param>
        /// <returns></returns>
        public FeatureSetQuery Query(
            int layerId,
            string query,
            WKID outSR,
            esriSpatialRelationship relationship,
            Geometry geometry    = null,
            bool returnGeometry  = true,
            int[] objectIds      = null,
            string outFields     = "",
            bool returnIdsOnly   = false,
            bool returnCountOnly = false)
        {
            LayerTableInfo layer = this.LayerInfos.Single(x => x.ID == layerId);

            if (layer == null)
            {
                Throw.ArgumentOutOfRange("layerId");
            }
            IDictionary <string, object> inputs = new Dictionary <string, object>()
            {
                { "returnGeometry", returnGeometry.ToString() },
                { "returnIdsOnly", returnIdsOnly },
                { "returnCountOnly", returnCountOnly },
                { "outFields", outFields },
                { "where", query },
                { "objectIds", objectIds },
            };

            if (outSR != WKID.NotSpecified)
            {
                inputs.Add("outSR", outSR);
            }
            if (geometry != null)
            {
                try
                {
                    ValidateGeometry(geometry);
                }
                catch (ArgumentNullException ex)
                {
                    Throw.InvalidOperation("",
                                           x => new InvalidOperationException("Geometry object is invalid.", ex));
                }
                inputs.Add("geometry", geometry);
                inputs.Add("geometryType", geometry.GeometryType);
                inputs.Add("spatialRel", relationship);
                inputs.Add("inSR", geometry.SpatialReference.WKID);
            }

            Uri endpoint = GetUrl(string.Format("{0}/query", layer.ID), inputs);

            return(Geocrest.Model.RestHelper.HydrateObject <FeatureSetQuery>(endpoint.ToString()));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Performs a query on the specified layer.
 /// </summary>
 /// <param name="layerId">The id of the layer to query.</param>
 /// <param name="query">A where clause for the query filter. Any legal SQL where clause operating on the fields in the layer is allowed.</param>
 /// <param name="outSR">The spatial reference of the returned geometry.</param>
 /// <param name="returnGeometry">If true, the resultset includes the geometry associated with each result.</param>
 /// <param name="objectIds">The object IDs of this layer / table to be queried.</param>
 /// <param name="outFields">The list of fields to be included in the returned resultset.</param>
 /// <param name="returnIdsOnly">If true, the response only includes an array of object IDs. Otherwise the response is a feature set.</param>
 /// <param name="returnCountOnly">If true, the response only includes the count (number of features / records) that would be returned by a query. Otherwise the response is a feature set.</param>
 /// <returns></returns>
 /// <exception cref="System.NotImplementedException"></exception>
 public FeatureSetQuery Query(
     int layerId,
     string query,
     WKID outSR,
     bool returnGeometry  = true,
     int[] objectIds      = null,
     string outFields     = "",
     bool returnIdsOnly   = false,
     bool returnCountOnly = false)
 {
     return(Query(layerId, query, outSR, esriSpatialRelationship.esriSpatialRelContains,
                  null, returnGeometry, objectIds, outFields, returnIdsOnly, returnCountOnly));
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Projects the input geometries to a new spatial reference.
        /// </summary>
        /// <param name="geometries">The array of geometries to be projected.</param>
        /// <param name="inSR">The well-known ID of the spatial reference for the input geometries.</param>
        /// <param name="outSR">The well-known ID of the spatial reference for the returned geometries.</param>
        public GeometryCollection Project(GeometryCollection geometries, WKID inSR, WKID outSR)
        {
            Throw.IfArgumentNull(geometries, "geometries");
            Throw.IfArgumentNull(inSR, "inSR");
            Throw.IfArgumentNull(outSR, "outSR");

            IDictionary <string, object> inputs = new Dictionary <string, object>
            {
                { "geometries", geometries },
                { "inSR", inSR },
                { "outSR", outSR }
            };
            Uri endpoint = GetUrl(GEOMETRY.Project, inputs);

            return(Geocrest.Model.RestHelper.HydrateObject <GeometryCollection>(endpoint.ToString()));
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Projects the input geometries to a new spatial reference.
 /// </summary>
 /// <param name="geometries">The array of geometries to be projected.</param>
 /// <param name="inSR">The well-known ID of the spatial reference for the input geometries.</param>
 /// <param name="outSR">The well-known ID of the spatial reference for the returned geometries.</param>
 /// <param name="callback">The callback function used to retrieve the results.</param>
 /// <exception cref="T:System.NotImplementedException">This method is currently not implemented.</exception>
 public void ProjectAsync(GeometryCollection geometries, WKID inSR, WKID outSR, Action <GeometryCollection> callback)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 6
0
        ///// <summary>
        ///// Reverses geocodes the input location.
        ///// </summary>
        ///// <param name="location">The point at which to search for the closest address.</param>
        ///// <param name="distance">The distance in meters from the given location within which a matching address should be searched.</param>
        ///// <param name="outSR">The well-known ID of the spatial reference for the returned address candidate.</param>
        ///// <param name="callback">The callback function used to retrieve the results.</param>
        //public void ReverseGeocodeAsync(Geometry location, double distance, WKID outSR, Action<ReverseGeocodedAddress> callback)
        //{
        //    Throw.IfArgumentNull(location, "location");
        //    Throw.IfNullableIsNull(location.X, "X");
        //    Throw.IfNullableIsNull(location.Y, "Y");
        //    IDictionary<string, object> inputs = new Dictionary<string, object>
        //        {
        //            { "location", location.X.Value.ToString() + "," + location.Y.Value.ToString() },
        //            { "distance", distance }
        //        };
        //    if (outSR != WKID.NotSpecified) inputs.Add("outSR", (int)outSR);
        //    string endpoint = GetUrl("reverseGeocode", inputs);
        //    this.RestHelper.HydrateAsync<ReverseGeocodedAddress>(endpoint, callback);
        //}

        /// <summary>
        /// Reverses geocodes the input location.
        /// </summary>
        /// <param name="location">The point at which to search for the closest address.</param>
        /// <param name="distance">The distance in meters from the given location within which a matching address should be searched.</param>
        /// <param name="outSR">The well-known ID of the spatial reference for the returned address candidate.</param>
        public ReverseGeocodedAddress ReverseGeocode(Geometry location, double distance, WKID outSR)
        {
            Throw.IfArgumentNull(location, "location");
            Throw.IfNullableIsNull(location.X, "X");
            Throw.IfNullableIsNull(location.Y, "Y");
            IDictionary <string, object> inputs = new Dictionary <string, object>
            {
                //{ "location", location.X.Value.ToString() + "," + location.Y.Value.ToString() },
                { "location", location.ToString() },
                { "distance", distance }
            };

            if (outSR != WKID.NotSpecified)
            {
                inputs.Add("outSR", (int)outSR);
            }
            Uri endpoint = GetUrl("reverseGeocode", inputs);

            return(Geocrest.Model.RestHelper.HydrateObject <ReverseGeocodedAddress>(endpoint.ToString()));
        }
Ejemplo n.º 7
0
        ///// <summary>
        ///// Finds address candidates matching the input address values.
        ///// </summary>
        ///// <param name="addressFields">An object of the type <see cref="IDictionary&lt;System.String,System.String&gt;">IDicationary&lt;System.String,System.String&gt;</see>.</param>
        ///// <param name="outSR">The well-known ID of the spatial reference for the returned address candidates.</param>
        ///// <param name="callback">The callback function used to retrieve the results.</param>
        ///// <param name="singleLineInput">The full address.</param>
        ///// <param name="outFields">The list of fields to be included in the returned resultset. This list is a comma-delimited list of field names.</param>
        //public void FindAddressCandidatesAsync(IDictionary<string, object> addressFields, WKID outSR,
        //    System.Action<AddressCandidateCollection> callback, string singleLineInput = "", string outFields = "")
        //{
        //    Throw.IfArgumentNull(addressFields, "inputs");
        //    if (outSR != WKID.NotSpecified) addressFields.Add(GEOCODE.FindAddressCandidatesParam.outSR, (int)outSR);
        //    addressFields.Add(this.SingleLineAddressField.Name, singleLineInput);
        //    addressFields.Add(GEOCODE.FindAddressCandidatesParam.outFields, outFields);
        //    string endpoint = GetUrl(GEOCODE.FindAddressCandidates, addressFields);
        //    this.RestHelper.HydrateAsync<AddressCandidateCollection>(endpoint, callback);
        //}

        /// <summary>
        /// Finds address candidates matching the input address values.
        /// </summary>
        /// <param name="addressFields">The inputs to search for as a key/value collection of the field name and search text.</param>
        /// <param name="outSR">The well-known ID of the spatial reference for the returned address candidates.</param>
        /// <param name="singleLineInput">The full address.</param>
        /// <param name="outFields">The list of fields to be included in the returned resultset. This list is a comma-delimited list of field names.</param>
        /// <returns>
        /// Returns an instance of <see cref="T:Geocrest.Model.ArcGIS.Tasks.AddressCandidateCollection"/>.
        /// </returns>
        public AddressCandidateCollection FindAddressCandidates(IDictionary <string, object> addressFields, WKID outSR, string singleLineInput = "", string outFields = "")
        {
            if (addressFields == null)
            {
                addressFields = new Dictionary <string, object> {
                };
                if (string.IsNullOrEmpty(singleLineInput))
                {
                    Throw.ArgumentException("addressFields AND singleLineInput");
                }
            }
            //Throw.IfArgumentNull(addressFields, "addressFields");
            if (outSR != WKID.NotSpecified)
            {
                addressFields.Add(GEOCODE.FindAddressCandidatesParam.outSR, (int)outSR);
            }
            addressFields.Add(this.SingleLineAddressField.Name, singleLineInput);
            addressFields.Add(GEOCODE.FindAddressCandidatesParam.outFields, outFields);
            Uri endpoint = GetUrl(GEOCODE.FindAddressCandidates, addressFields);

            return(Geocrest.Model.RestHelper.HydrateObject <AddressCandidateCollection>(endpoint.ToString()));
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:Geocrest.Model.ArcGIS.Geometry.SpatialReference"/> class.
 /// </summary>
 /// <param name="wkid">A well-known spatial reference ID.</param>
 public SpatialReference(WKID wkid)
 {
     this.WKID = wkid;
 }