Exemplo n.º 1
0
        protected override BaseShape CreateAccessibleAreaCore()
        {
            string rtgFilePathName = Path.ChangeExtension(StreetShapeFilePathName, ".rtg");

            RtgRoutingSource routingSource = new RtgRoutingSource(rtgFilePathName);
            FeatureSource    featureSource = new ShapeFileFeatureSource(StreetShapeFilePathName);
            RoutingEngine    routingEngine = new RoutingEngine(routingSource, featureSource);

            if (!featureSource.IsOpen)
            {
                featureSource.Open();
            }
            ManagedProj4Projection proj = new ManagedProj4Projection();

            proj.InternalProjectionParametersString = ManagedProj4Projection.GetBingMapParametersString();
            proj.ExternalProjectionParametersString = ManagedProj4Projection.GetEpsgParametersString(4326);

            proj.Open();
            StartLocation = proj.ConvertToExternalProjection(StartLocation) as PointShape;

            Feature      feature      = featureSource.GetFeaturesNearestTo(StartLocation, GeographyUnit, 1, ReturningColumnsType.NoColumns)[0];
            PolygonShape polygonShape = routingEngine.GenerateServiceArea(feature.Id, new TimeSpan(0, DrivingTimeInMinutes, 0), 100, GeographyUnit.Feet);

            polygonShape = proj.ConvertToInternalProjection(polygonShape) as PolygonShape;

            proj.Close();

            return(polygonShape);
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.DisplayASimpleMap);

            androidMap              = FindViewById <MapView>(Resource.Id.androidmap);
            androidMap.MapUnit      = GeographyUnit.Meter;
            androidMap.ZoomLevelSet = new GoogleMapsZoomLevelSet();

            GoogleMapsOverlay googleMapsOverlay = new GoogleMapsOverlay();

            googleMapsOverlay.TileType = TileType.MultiTile;
            androidMap.Overlays.Add(googleMapsOverlay);

            ManagedProj4Projection proj4 = new ManagedProj4Projection();

            proj4.InternalProjectionParametersString = ManagedProj4Projection.GetDecimalDegreesParametersString();
            proj4.ExternalProjectionParametersString = ManagedProj4Projection.GetGoogleMapParametersString();
            proj4.Open();

            androidMap.CurrentExtent = proj4.ConvertToExternalProjection(new RectangleShape(-139.2, 92.4, 120.9, -93.2)) as RectangleShape;

            SampleViewHelper.InitializeInstruction(this, FindViewById <RelativeLayout>(Resource.Id.MainLayout), GetType());
        }
        private void FilterEarthquake()
        {
            FilteredQueryResults.Clear();

            ManagedProj4Projection mercatorToWgs84Projection = new ManagedProj4Projection();
            mercatorToWgs84Projection.InternalProjectionParametersString = ManagedProj4Projection.GetSphericalMercatorParametersString();
            mercatorToWgs84Projection.ExternalProjectionParametersString = ManagedProj4Projection.GetDecimalDegreesParametersString();
            mercatorToWgs84Projection.Open();

            for (int i = queryResults.Count - 1; i >= 0; i--)
            {
                EarthquakeViewModel resultItem = queryResults[i];

                double latitude, longitude;
                if (double.TryParse(resultItem.Latitude, out latitude) && double.TryParse(resultItem.Longitude, out longitude))
                {
                    PointShape point = new PointShape(longitude, latitude);
                    point = (PointShape)mercatorToWgs84Projection.ConvertToExternalProjection(point);

                    EarthquakeViewModel newResultItem = new EarthquakeViewModel(resultItem.EpicenterFeature);
                    newResultItem.Latitude = point.Y.ToString("f3", CultureInfo.InvariantCulture);
                    newResultItem.Longitude = point.X.ToString("f3", CultureInfo.InvariantCulture);

                    double year, depth, magnitude;
                    double.TryParse(newResultItem.Magnitude, out magnitude);
                    double.TryParse(newResultItem.DepthInKilometer, out depth);
                    double.TryParse(newResultItem.Year, out year);

                    if ((magnitude >= queryFilter.StartMagnitudeRange && magnitude <= queryFilter.EndMagnitudeRange || newResultItem.Magnitude == Resources.UnknownString)
                        && (depth <= queryFilter.EndDepthRange && depth >= queryFilter.StartDepthRange || newResultItem.DepthInKilometer == Resources.UnknownString)
                        && (year >= queryFilter.StartYearRange && year <= queryFilter.EndYearRange) || newResultItem.Year == Resources.UnknownString)
                    {
                        FilteredQueryResults.Add(newResultItem);
                    }
                }
            }

            mercatorToWgs84Projection.Close();
            mapModel.RefreshMarkersByFeatures(FilteredQueryResults.Select(f => f.EpicenterFeature));
        }