示例#1
0
        public async Task QueryOutFieldsAreHonored()
        {
            var gateway = new ArcGISGateway(_jsonDotNetSerializer);

            var queryPolyline = new Query(@"Hydrography/Watershed173811/MapServer/1".AsEndpoint())
            {
                OutFields = new List <String> {
                    "lengthkm"
                }, ReturnGeometry = false
            };
            var resultPolyline = await gateway.Query <Polyline>(queryPolyline);

            Assert.True(resultPolyline.Features.Any());
            Assert.True(resultPolyline.Features.All(i => i.Geometry == null));
            Assert.True(resultPolyline.Features.All(i => i.Attributes != null && i.Attributes.Count == 1));

            var queryPolygon = new Query(@"/Hydrography/Watershed173811/MapServer/0".AsEndpoint())
            {
                Where     = "areasqkm = 0.012",
                OutFields = new List <String> {
                    "areasqkm", "elevation", "resolution", "reachcode"
                }
            };
            var resultPolygon = await gateway.Query <Polygon>(queryPolygon);

            Assert.True(resultPolygon.Features.Any());
            Assert.True(resultPolygon.Features.All(i => i.Geometry != null));
            Assert.True(resultPolygon.Features.All(i => i.Attributes != null && i.Attributes.Count == 4));
        }
示例#2
0
        public async Task QueryObjectIdsAreHonored()
        {
            var gateway = new ArcGISGateway(_serviceStackSerializer);

            var queryPoint = new Query(@"Earthquakes/EarthquakesFromLastSevenDays/MapServer/0".AsEndpoint())
            {
                ReturnGeometry = false
            };
            var resultPoint = await gateway.Query <Point>(queryPoint);

            Assert.True(resultPoint.Features.Any());
            Assert.True(resultPoint.Features.All(i => i.Geometry == null));

            var queryPointByOID = new Query(@"Earthquakes/EarthquakesFromLastSevenDays/MapServer/0".AsEndpoint())
            {
                ReturnGeometry = false,
                ObjectIds      = resultPoint.Features.Take(10).Select(f => int.Parse(f.Attributes["objectid"].ToString())).ToList()
            };
            var resultPointByOID = await gateway.Query <Point>(queryPointByOID);

            Assert.True(resultPointByOID.Features.Any());
            Assert.True(resultPointByOID.Features.All(i => i.Geometry == null));
            Assert.True(resultPoint.Features.Count() > 10);
            Assert.True(resultPointByOID.Features.Count() == 10);
        }
示例#3
0
        /// <summary>
        /// Performs unfiltered query, then filters by Extent and Polygon to SE quadrant of globe and verifies both filtered
        /// results contain same number of features as each other, and that both filtered resultsets contain fewer features than unfiltered resultset.
        /// </summary>
        /// <param name="serviceUrl"></param>
        /// <returns></returns>
        public async Task QueryGeometryCriteriaHonored(string serviceUrl)
        {
            int countAllResults     = 0;
            int countExtentResults  = 0;
            int countPolygonResults = 0;

            var gateway = new ArcGISGateway(_jsonDotNetSerializer);

            var queryPointAllResults = new Query(serviceUrl.AsEndpoint());

            var resultPointAllResults = await gateway.Query <Point>(queryPointAllResults);

            var queryPointExtentResults = new Query(serviceUrl.AsEndpoint())
            {
                Geometry = new Extent {
                    XMin = 0, YMin = 0, XMax = 180, YMax = -90, SpatialReference = SpatialReference.WGS84
                },                                                                                                               // SE quarter of globe
                OutputSpatialReference = SpatialReference.WebMercator
            };
            var resultPointExtentResults = await gateway.Query <Point>(queryPointExtentResults);

            var rings = new Point[]
            {
                new Point {
                    X = 0, Y = 0
                },
                new Point {
                    X = 180, Y = 0
                },
                new Point {
                    X = 180, Y = -90
                },
                new Point {
                    X = 0, Y = -90
                },
                new Point {
                    X = 0, Y = 0
                }
            }.ToPointCollectionList();

            var queryPointPolygonResults = new Query(serviceUrl.AsEndpoint())
            {
                Geometry = new Polygon {
                    Rings = rings
                }
            };
            var resultPointPolygonResults = await gateway.Query <Point>(queryPointPolygonResults);

            countAllResults     = resultPointAllResults.Features.Count();
            countExtentResults  = resultPointExtentResults.Features.Count();
            countPolygonResults = resultPointPolygonResults.Features.Count();

            Assert.Equal(resultPointExtentResults.SpatialReference.Wkid, queryPointExtentResults.OutputSpatialReference.LatestWkid);
            Assert.True(countAllResults > countExtentResults);
            Assert.True(countPolygonResults == countExtentResults);
        }
示例#4
0
        public async Task QueryCanReturnDifferentGeometryTypes()
        {
            var gateway = new ArcGISGateway(_serviceStackSerializer);

            var queryPoint  = new Query(@"Earthquakes/EarthquakesFromLastSevenDays/MapServer/0".AsEndpoint());
            var resultPoint = await gateway.QueryAsPost <Point>(queryPoint);

            Assert.True(resultPoint.Features.Any());
            Assert.True(resultPoint.Features.All(i => i.Geometry != null));

            var queryPolyline = new Query(@"Hydrography/Watershed173811/MapServer/1".AsEndpoint())
            {
                OutFields = new List <String> {
                    "lengthkm"
                }
            };
            var resultPolyline = await gateway.Query <Polyline>(queryPolyline);

            Assert.True(resultPolyline.Features.Any());
            Assert.True(resultPolyline.Features.All(i => i.Geometry != null));

            gateway = new ArcGISGateway(_jsonDotNetSerializer);

            var queryPolygon = new Query(@"/Hydrography/Watershed173811/MapServer/0".AsEndpoint())
            {
                Where = "areasqkm = 0.012", OutFields = new List <String> {
                    "areasqkm"
                }
            };
            var resultPolygon = await gateway.QueryAsPost <Polygon>(queryPolygon);

            Assert.True(resultPolygon.Features.Any());
            Assert.True(resultPolygon.Features.All(i => i.Geometry != null));
        }
示例#5
0
        public async Task QueryCanReturnNoGeometry()
        {
            var gateway = new ArcGISGateway(_serviceStackSerializer);

            var queryPoint = new Query(@"Earthquakes/EarthquakesFromLastSevenDays/MapServer/0".AsEndpoint())
            {
                ReturnGeometry = false
            };
            var resultPoint = await gateway.Query <Point>(queryPoint);

            Assert.True(resultPoint.Features.Any());
            Assert.True(resultPoint.Features.All(i => i.Geometry == null));

            var queryPolyline = new Query(@"Hydrography/Watershed173811/MapServer/1".AsEndpoint())
            {
                OutFields = new List <String> {
                    "lengthkm"
                }, ReturnGeometry = false
            };
            var resultPolyline = await gateway.QueryAsPost <Polyline>(queryPolyline);

            Assert.True(resultPolyline.Features.Any());
            Assert.True(resultPolyline.Features.All(i => i.Geometry == null));
        }
示例#6
0
        public async Task GatewayDoesAutoPost()
        {
            var gateway = new ArcGISGateway(_serviceStackSerializer);

            var longWhere = new StringBuilder("region = '");

            for (var i = 0; i < 3000; i++)
            {
                longWhere.Append(i);
            }

            var query = new Query(@"/Earthquakes/EarthquakesFromLastSevenDays/MapServer/0".AsEndpoint())
            {
                Where = longWhere + "'"
            };

            var exception = await SecureGISGatewayTests.ThrowsAsync <InvalidOperationException>(async() => await gateway.Query <Point>(query));

            Assert.NotNull(exception);
            Assert.Contains("Unable to complete Query operation", exception.Message);
        }