Exemplo n.º 1
0
        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);
		}
Exemplo n.º 3
0
        public async Task CanGeocode(string rootUrl, string relativeUrl, string text, string sourceCountry = "")
        {
            var gateway = new PortalGateway(rootUrl);
            var geocode = new SingleInputGeocode(relativeUrl.AsEndpoint())
            {
                Text          = text,
                SourceCountry = sourceCountry
            };
            var response = await gateway.Geocode(geocode);

            Assert.Null(response.Error);
            Assert.NotNull(response.SpatialReference);
            Assert.NotNull(response.Results);
            Assert.True(response.Results.Any());
            var result = response.Results.First();

            Assert.NotNull(result.Feature);
            Assert.NotNull(result.Feature.Geometry);
        }
Exemplo n.º 4
0
        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);
            };
        }
Exemplo n.º 5
0
        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);
            };
        }
Exemplo n.º 6
0
        public async Task CanGeocode(string rootUrl, string relativeUrl, string text, string sourceCountry = "")
        {
            var gateway = new PortalGateway(rootUrl);
            var geocode = new SingleInputGeocode(relativeUrl)
            {
                Text          = text,
                SourceCountry = sourceCountry
            };
            var response = await IntegrationTestFixture.TestPolicy.ExecuteAsync(() =>
            {
                return(gateway.Geocode(geocode));
            });

            Assert.Null(response.Error);
            Assert.NotNull(response.SpatialReference);
            Assert.NotNull(response.Results);
            Assert.True(response.Results.Any());
            var result = response.Results.First();

            Assert.NotNull(result.Feature);
            Assert.NotNull(result.Feature.Geometry);
        }