public async Task CanPagePointQuery(string rootUrl, string relativeUrl, int start, int numberToReturn) { var gateway = new PortalGateway(rootUrl); var queryCount = new QueryForCount(relativeUrl.AsEndpoint()); var resultCount = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => { return(gateway.QueryForCount(queryCount)); }); Assert.NotNull(resultCount); Assert.Null(resultCount.Error); Assert.NotEqual(numberToReturn, resultCount.NumberOfResults); Assert.True(numberToReturn < resultCount.NumberOfResults); var query = new Query(relativeUrl.AsEndpoint()) { ResultOffset = start, ResultRecordCount = numberToReturn }; var result = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => { return(gateway.Query <Point>(query)); }); Assert.NotNull(result); Assert.Null(result.Error); Assert.True(result.Features.Any()); Assert.Equal(numberToReturn, result.Features.Count()); }
public async Task CanSimplify() { var gateway = new PortalGateway("http://sampleserver1.arcgisonline.com/ArcGIS"); var result = await IntegrationTestFixture.TestPolicy.Execute(() => { return(gateway.Query <Polygon>(new Query("Demographics/ESRI_Census_USA/MapServer/5") { Where = "STATE_NAME = 'Oregon'" })); }); var features = result.Features.Where(f => f.Geometry.Rings.Any()).ToList(); Assert.NotNull(features); Assert.True(result.SpatialReference.Wkid != SpatialReference.WGS84.Wkid); Assert.True(features[0].Geometry.Rings.Count > 0); features[0].Geometry.SpatialReference = result.SpatialReference; var simplifiedFeatures = await IntegrationTestFixture.TestPolicy.Execute(() => { return(new ArcGISOnlineGateway().Simplify <Polygon>(features, result.SpatialReference)); }); Assert.NotNull(simplifiedFeatures); Assert.Equal(features.Count, simplifiedFeatures.Count); Assert.True(features[0].Geometry.Rings.Count > 0); Assert.True(simplifiedFeatures[0].Geometry.Rings.Count > 0); Assert.NotEqual(features, simplifiedFeatures); Assert.NotEqual(simplifiedFeatures[0].Geometry.Rings[0], features[0].Geometry.Rings[0]); }
public async Task CanProject() { var gateway = new PortalGateway("http://sampleserver1.arcgisonline.com/ArcGIS"); var result = await IntegrationTestFixture.TestPolicy.Execute(() => { return(gateway.Query <Polygon>(new Query("Demographics/ESRI_Census_USA/MapServer/5") { Where = "STATE_NAME = 'Oregon'" })); }); var features = result.Features.Where(f => f.Geometry.Rings.Any()).ToList(); Assert.NotNull(features); Assert.True(result.SpatialReference.Wkid != SpatialReference.WGS84.Wkid); Assert.True(features[0].Geometry.Rings.Count > 0); features[0].Geometry.SpatialReference = result.SpatialReference; var projectedFeatures = await IntegrationTestFixture.TestPolicy.Execute(() => { return(new ArcGISOnlineGateway().Project <Polygon>(features, SpatialReference.WGS84)); }); Assert.NotNull(projectedFeatures); Assert.Equal(features.Count, projectedFeatures.Count); Assert.True(features[0].Geometry.Rings.Count > 0); // If this fails, 2 issues: 1) features has been shallow copied, and 2) geometries aren't being populated. Assert.True(projectedFeatures[0].Geometry.Rings.Count > 0); // If this fails, just problem 2 above - geometries aren't being copied. Assert.NotEqual(features, projectedFeatures); Assert.NotEqual(projectedFeatures[0].Geometry.Rings[0], features[0].Geometry.Rings[0]); }
public async Task QueryForOutputStatistics() { var gateway = new PortalGateway("http://services.arcgis.com/P3ePLMYs2RVChkJx/ArcGIS"); var outStats = new List <OutputStatistic>(); outStats.Add(new OutputStatistic() { StatisticType = StatisticTypes.Average, OnField = "MALES", OutField = "AVE_MALES" }); outStats.Add(new OutputStatistic() { StatisticType = StatisticTypes.Sum, OnField = "MALES", OutField = "SUM_MALES" }); var query = new Query("USA_Major_Cities/FeatureServer/0") { GroupByFields = new List <string>(new string[] { "ST" }), OutputStatistics = outStats }; var result = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => { return(gateway.Query <Point>(query)); }); Assert.NotNull(result); Assert.Null(result.Error); Assert.True(result.Features.Any()); Assert.NotNull(result.Fields); Assert.True(result.Fields.Where(x => x.Name == "SUM_MALES").Any()); }
public override void ViewDidLoad() { base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. View.Frame = UIScreen.MainScreen.Bounds; View.BackgroundColor = UIColor.White; View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; button = UIButton.FromType(UIButtonType.RoundedRect); button.Frame = new RectangleF( (float)(View.Frame.Width / 2 - buttonWidth / 2), buttonHeight, buttonWidth, buttonHeight); button.SetTitle("GO", UIControlState.Normal); textView = new UITextView(new RectangleF( (float)(View.Frame.Width / 2 - buttonWidth / 2), (float)((View.Frame.Height / 2 - buttonHeight / 2) - buttonHeight), buttonWidth, (float)((View.Frame.Height / 2 - buttonHeight / 2) - buttonHeight))); ArcGIS.ServiceModel.Serializers.JsonDotNetSerializer.Init(); var locator = new PortalGateway("http://geocode.arcgis.com/arcgis"); var geocode = new SingleInputGeocode("/World/GeocodeServer/".AsEndpoint()) { Text = "Wellington", SourceCountry = "NZL" }; var gateway = new PortalGateway("http://sampleserver3.arcgisonline.com/ArcGIS/"); var queryPoint = new Query(@"Earthquakes/EarthquakesFromLastSevenDays/MapServer/0".AsEndpoint()) { ReturnGeometry = false, Where = "MAGNITUDE > 4.5" }; button.TouchUpInside += async(object sender, EventArgs e) => { var geocodeResult = await locator.Geocode(geocode); var resultPoint = await gateway.Query <ArcGIS.ServiceModel.Common.Point>(queryPoint); textView.Text = string.Format("Query for earthquakes in last 7 days where magnitidue is more than 4.5, {0} features found. Geocode result for Wellington, NZ x:{1}, y:{2}", resultPoint.Features.Count(), geocodeResult.Results.First().Feature.Geometry.X, geocodeResult.Results.First().Feature.Geometry.Y); }; button.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleBottomMargin; View.AddSubview(button); View.Add(textView); }
public override void ViewDidLoad () { base.ViewDidLoad (); // Perform any additional setup after loading the view, typically from a nib. View.Frame = UIScreen.MainScreen.Bounds; View.BackgroundColor = UIColor.White; View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; button = UIButton.FromType(UIButtonType.RoundedRect); button.Frame = new RectangleF( (float)(View.Frame.Width / 2 - buttonWidth / 2), buttonHeight, buttonWidth, buttonHeight); button.SetTitle("GO", UIControlState.Normal); textView = new UITextView(new RectangleF( (float)(View.Frame.Width / 2 - buttonWidth / 2), (float)((View.Frame.Height / 2 - buttonHeight / 2) - buttonHeight), buttonWidth, (float)((View.Frame.Height / 2 - buttonHeight / 2) - buttonHeight))); ArcGIS.ServiceModel.Serializers.JsonDotNetSerializer.Init(); var locator = new PortalGateway("http://geocode.arcgis.com/arcgis"); var geocode = new SingleInputGeocode("/World/GeocodeServer/".AsEndpoint()) { Text = "Wellington", SourceCountry = "NZL" }; var gateway = new PortalGateway("http://sampleserver3.arcgisonline.com/ArcGIS/"); var queryPoint = new Query(@"Earthquakes/EarthquakesFromLastSevenDays/MapServer/0".AsEndpoint()) { ReturnGeometry = false, Where = "MAGNITUDE > 4.5" }; button.TouchUpInside += async (object sender, EventArgs e) => { var geocodeResult = await locator.Geocode(geocode); var resultPoint = await gateway.Query<ArcGIS.ServiceModel.Common.Point>(queryPoint); textView.Text = string.Format("Query for earthquakes in last 7 days where magnitidue is more than 4.5, {0} features found. Geocode result for Wellington, NZ x:{1}, y:{2}", resultPoint.Features.Count(), geocodeResult.Results.First().Feature.Geometry.X, geocodeResult.Results.First().Feature.Geometry.Y); }; button.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleBottomMargin; View.AddSubview(button); View.Add(textView); }
public async Task QueryOrderByIsHonored(string rootUrl, string relativeUrl, string orderby) { var gateway = new PortalGateway(rootUrl); var query = new Query(relativeUrl.AsEndpoint()) { OrderBy = new List <string> { orderby }, ReturnGeometry = false, Where = "CITY = 'WA'" }; var result = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => { return(gateway.Query <Point>(query)); }); var queryDesc = new Query(relativeUrl) { OrderBy = new List <string> { orderby + " DESC" }, ReturnGeometry = false, Where = "CITY = 'WA'" }; var resultDesc = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => { return(gateway.Query <Point>(queryDesc)); }); Assert.True(result.Features.Any()); Assert.True(resultDesc.Features.Any()); Assert.True(result.Features.Count() == resultDesc.Features.Count()); Assert.Equal(result.Features.First().Attributes[orderby], resultDesc.Features.Last().Attributes[orderby]); Assert.Equal(result.Features.Last().Attributes[orderby], resultDesc.Features.First().Attributes[orderby]); }
public async Task CanQueryWithNoGeometryResponse() { var gateway = new PortalGateway("http://services.arcgisonline.com/arcgis/"); var query = new Query(@"/Specialty/Soil_Survey_Map/MapServer/2"); var result = await IntegrationTestFixture.TestPolicy.Execute(() => { return(gateway.Query(query)); }); Assert.NotNull(result); Assert.Null(result.Error); Assert.NotNull(result.Features); Assert.True(result.Features.All(x => x.Geometry == null)); }
public async Task QueryCanReturnPointFeatures(string rootUrl, string relativeUrl) { var gateway = new PortalGateway(rootUrl); var query = new Query(relativeUrl.AsEndpoint()); var result = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => { return(gateway.Query <Point>(query)); }); Assert.NotNull(result); Assert.Null(result.Error); Assert.NotNull(result.SpatialReference); Assert.True(result.Features.Any()); Assert.Null(result.Links); Assert.True(result.Features.All(i => i.Geometry != null)); }
public async Task CanBuffer(string rootUrl, string relativeUrl, string where) { var gateway = new PortalGateway(rootUrl); var result = await IntegrationTestFixture.TestPolicy.Execute(() => { return(gateway.Query <Polygon>(new Query(relativeUrl) { Where = where })); }); var features = result.Features.Where(f => f.Geometry.Rings.Any()).ToList(); Assert.NotNull(features); await Buffer(gateway, features, result.SpatialReference); }
public async Task CanBuffer() { var gateway = new PortalGateway("http://sampleserver1.arcgisonline.com/ArcGIS"); var result = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() => { return(gateway.Query <Polygon>(new Query("Demographics/ESRI_Census_USA/MapServer/5".AsEndpoint()) { Where = "STATE_NAME = 'Texas'" })); }); var features = result.Features.Where(f => f.Geometry.Rings.Any()).ToList(); Assert.NotNull(features); await Buffer(gateway, features, result.SpatialReference); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById<Button>(Resource.Id.myButton); TextView textview = FindViewById<TextView>(Resource.Id.textView1); ArcGIS.ServiceModel.Serializers.JsonDotNetSerializer.Init(); var locator = new PortalGateway("http://geocode.arcgis.com/arcgis"); var geocode = new SingleInputGeocode("/World/GeocodeServer/".AsEndpoint()) { Text = "Wellington", SourceCountry = "NZL" }; var gateway = new PortalGateway("http://sampleserver3.arcgisonline.com/ArcGIS/"); var queryPoint = new Query(@"Earthquakes/EarthquakesFromLastSevenDays/MapServer/0".AsEndpoint()) { ReturnGeometry = false, Where = "MAGNITUDE > 4.5" }; button.Click += async delegate { var geocodeResult = await locator.Geocode(geocode); var resultPoint = await gateway.Query<Point>(queryPoint); textview.Text = string.Format("Query for earthquakes in last 7 days where magnitude is more than 4.5, {0} features found. Geocode result for Wellington, NZ x:{1}, y:{2}", resultPoint.Features.Count(), geocodeResult.Results.First().Feature.Geometry.X, geocodeResult.Results.First().Feature.Geometry.Y); }; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our button from the layout resource, // and attach an event to it Button button = FindViewById <Button>(Resource.Id.myButton); TextView textview = FindViewById <TextView>(Resource.Id.textView1); ArcGIS.ServiceModel.Serializers.JsonDotNetSerializer.Init(); var locator = new PortalGateway("http://geocode.arcgis.com/arcgis"); var geocode = new SingleInputGeocode("/World/GeocodeServer/".AsEndpoint()) { Text = "Wellington", SourceCountry = "NZL" }; var gateway = new PortalGateway("http://sampleserver3.arcgisonline.com/ArcGIS/"); var queryPoint = new Query(@"Earthquakes/EarthquakesFromLastSevenDays/MapServer/0".AsEndpoint()) { ReturnGeometry = false, Where = "MAGNITUDE > 4.5" }; button.Click += async delegate { var geocodeResult = await locator.Geocode(geocode); var resultPoint = await gateway.Query <Point>(queryPoint); textview.Text = string.Format("Query for earthquakes in last 7 days where magnitude is more than 4.5, {0} features found. Geocode result for Wellington, NZ x:{1}, y:{2}", resultPoint.Features.Count(), geocodeResult.Results.First().Feature.Geometry.X, geocodeResult.Results.First().Feature.Geometry.Y); }; }
public async Task InvalidTokenReported(string rootUrl, string username, string password, string relativeUrl) { var tokenProvider = new TokenProvider(rootUrl, username, password); var gateway = new PortalGateway(rootUrl, tokenProvider: tokenProvider); var endpoint = new ArcGISServerEndpoint(relativeUrl); var token = await IntegrationTestFixture.TestPolicy.Execute(() => { return(tokenProvider.CheckGenerateToken(CancellationToken.None)); }); Assert.NotNull(token); Assert.NotNull(token.Value); Assert.False(token.IsExpired); Assert.Null(token.Error); token.Value += "chuff"; var query = new Query(endpoint) { Token = token.Value }; var exception = await Assert.ThrowsAsync <InvalidOperationException>(() => gateway.Query <Point>(query)); Assert.NotNull(exception); Assert.Contains("invalid token", exception.Message.ToLowerInvariant()); }