Beispiel #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);
        }
Beispiel #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.DisplayASimpleMap);

            ManagedProj4Projection proj4Projection = new ManagedProj4Projection();

            proj4Projection.InternalProjectionParametersString = ManagedProj4Projection.GetEpsgParametersString(4326);
            proj4Projection.ExternalProjectionParametersString = ManagedProj4Projection.GetGoogleMapParametersString();

            ShapeFileFeatureLayer worldLayer = new ShapeFileFeatureLayer(SampleHelper.GetDataPath(@"SampleData/Countries02.shp"));

            worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(255, 233, 232, 214), GeoColor.FromArgb(255, 118, 138, 69));
            worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            worldLayer.FeatureSource.Projection = proj4Projection;

            LayerOverlay staticOverlay = new LayerOverlay();

            staticOverlay.Layers.Add(worldLayer);

            androidMap               = FindViewById <MapView>(Resource.Id.androidmap);
            androidMap.MapUnit       = GeographyUnit.Meter;
            androidMap.CurrentExtent = new RectangleShape(-13939426.6371, 6701997.4056, -7812401.86, 2626987.386962);
            androidMap.Overlays.Add(staticOverlay);

            SampleViewHelper.InitializeInstruction(this, FindViewById <RelativeLayout>(Resource.Id.MainLayout), GetType());
        }
Beispiel #3
0
        private void TestForm_Load(object sender, EventArgs e)
        {
            winformsMap1.MapUnit       = GeographyUnit.DecimalDegree;
            winformsMap1.CurrentExtent = new RectangleShape(-88.0309, 42.2772, -88.0036, 42.2609);
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.FromArgb(255, 198, 255, 255));

            //Displays the World Map Kit as a background.
            WorldMapKitWmsDesktopOverlay worldMapKitDesktopOverlay = new WorldMapKitWmsDesktopOverlay();

            winformsMap1.Overlays.Add(worldMapKitDesktopOverlay);

            ManagedProj4Projection proj4 = new ManagedProj4Projection();

            proj4.InternalProjectionParametersString = ManagedProj4Projection.GetEpsgParametersString(26916);
            proj4.ExternalProjectionParametersString = ManagedProj4Projection.GetEpsgParametersString(4326);

            ShapeFileFeatureLayer layer1 = new ShapeFileFeatureLayer(@"..\..\data\lake_streets_utm16.shp");

            layer1.ZoomLevelSet.ZoomLevel01.DefaultLineStyle    = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.DarkGreen, 4, true);
            layer1.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            layer1.FeatureSource.Projection = proj4;

            ShapeFileFeatureLayer layer2 = new ShapeFileFeatureLayer(@"..\..\data\lake_poly.shp");

            layer2.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(150, GeoColor.StandardColors.Green), GeoColor.StandardColors.Black);
            layer2.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay layerOverlay = new LayerOverlay();

            layerOverlay.Layers.Add(layer1);
            layerOverlay.Layers.Add(layer2);
            winformsMap1.Overlays.Add(layerOverlay);

            InMemoryFeatureLayer inMemoryFeatureLayer = new InMemoryFeatureLayer();

            inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle   = PointStyles.CreateSimpleCircleStyle(GeoColor.StandardColors.Red, 10);
            inMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            PointShape pointShape = new PointShape(-88.0168, 42.2688);

            inMemoryFeatureLayer.InternalFeatures.Add(new Feature(pointShape));

            InMemoryFeatureLayer selectInMemoryFeatureLayer = new InMemoryFeatureLayer();

            selectInMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = AreaStyles.CreateSimpleAreaStyle(GeoColor.StandardColors.Yellow);
            selectInMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle    = LineStyles.CreateSimpleLineStyle(GeoColor.StandardColors.Yellow, 3, true);
            selectInMemoryFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            double meterDistance = 300;

            layer1.Open();
            // This method works fine with Map Suite Assemblies 4.5.54.0 or later.
            Collection <Feature> withinFeatures1 = layer1.QueryTools.GetFeaturesWithinDistanceOf(pointShape, winformsMap1.MapUnit, DistanceUnit.Meter, meterDistance, ReturningColumnsType.AllColumns);

            layer1.Close();
            foreach (Feature withinFeature1 in withinFeatures1)
            {
                selectInMemoryFeatureLayer.InternalFeatures.Add(withinFeature1);
            }

            layer2.Open();
            Collection <Feature> withinFeatures2 = layer2.QueryTools.GetFeaturesWithinDistanceOf(pointShape, winformsMap1.MapUnit, DistanceUnit.Meter, meterDistance, ReturningColumnsType.AllColumns);

            layer2.Close();
            foreach (Feature withinFeature2 in withinFeatures2)
            {
                selectInMemoryFeatureLayer.InternalFeatures.Add(withinFeature2);
            }

            LayerOverlay dynamicOverlay = new LayerOverlay();

            dynamicOverlay.Layers.Add(inMemoryFeatureLayer);
            dynamicOverlay.Layers.Add(selectInMemoryFeatureLayer);
            winformsMap1.Overlays.Add(dynamicOverlay);

            ScaleBarAdornmentLayer scaleBarAdornmentLayer = new ScaleBarAdornmentLayer();

            scaleBarAdornmentLayer.UnitFamily = UnitSystem.Metric;
            scaleBarAdornmentLayer.Location   = AdornmentLocation.LowerLeft;
            winformsMap1.AdornmentOverlay.Layers.Add(scaleBarAdornmentLayer);

            winformsMap1.Refresh();
        }
Beispiel #4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);

            // WorldMapKitOverlay worldOverlay = new WorldMapKitOverlay();
            androidMap = FindViewById <MapView>(Resource.Id.androidmap);
            androidMap.TrackOverlay.VertexAdded += (sender, e) => { endVertex = e.AddedVertex; };
            androidMap.MapUnit = GeographyUnit.Meter;

            ShapeFileFeatureLayer shapeFileFeatureLayer = new ShapeFileFeatureLayer(System.IO.Path.Combine(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads).ToString(), "cadastral.shp"));

            shapeFileFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(
                GeoColor.FromArgb(100, GeoColor.StandardColors.White), GeoColor.StandardColors.Green);
            shapeFileFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle    = new TextStyle("Plotno_1", new GeoFont("Arail", 9, DrawingFontStyles.Bold), new GeoSolidBrush(GeoColor.SimpleColors.Black));
            shapeFileFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            ShapeFileFeatureLayer buildingLayer = new ShapeFileFeatureLayer(System.IO.Path.Combine(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads).ToString(), "building.shp"));

            buildingLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(
                GeoColor.FromArgb(100, GeoColor.StandardColors.Gray), GeoColor.StandardColors.Blue);
            buildingLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle    = new TextStyle("BLD_NO", new GeoFont("Arail", 9, DrawingFontStyles.Bold), new GeoSolidBrush(GeoColor.SimpleColors.Black));
            buildingLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            ShapeFileFeatureLayer hLayer = new ShapeFileFeatureLayer(System.IO.Path.Combine(Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDownloads).ToString(), "BLOCKs.shp"), ShapeFileReadWriteMode.ReadWrite);

            hLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = new TextStyle("BLOCKSch", new GeoFont("Arail", 9, DrawingFontStyles.Bold), new GeoSolidBrush(GeoColor.SimpleColors.Black));
            hLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.FillSolidBrush.Color = GeoColor.FromArgb(100, GeoColor.StandardColors.Blue);
            hLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.OutlinePen.Color     = GeoColor.StandardColors.Blue;
            hLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle.OuterPen             = new GeoPen(GeoColor.FromArgb(200, GeoColor.StandardColors.Red), 5);
            hLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.SymbolPen           = new GeoPen(GeoColor.FromArgb(255, GeoColor.StandardColors.Green), 8);
            hLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            pointLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle   = PointStyles.CreateSimpleCircleStyle(GeoColor.StandardColors.Red, 12, GeoColor.StandardColors.Black);
            pointLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            //  Feature gmp = new Feature(new PointShape(256721.2508062, 9855780.04717357));
            //  pointLayer.InternalFeatures.Add(gmp);
            LayerOverlay pointOverlay = new LayerOverlay( );

            pointOverlay.Layers.Add("PointLayer", pointLayer);

            //  LayerOverlay layerOverlay = new LayerOverlay();  moved to public
            layerOverlay.Layers.Add("Cadastral", shapeFileFeatureLayer);

            LayerOverlay hOverlay = new LayerOverlay();

            hOverlay.Layers.Add("Blocks", hLayer);

            LayerOverlay bOverlay = new LayerOverlay();

            bOverlay.Layers.Add("Building", buildingLayer);

            androidMap.Overlays.Add("building", bOverlay);
            androidMap.Overlays.Add("cadastral", layerOverlay);
            androidMap.Overlays.Add("blocks", hOverlay);
            androidMap.Overlays.Add("gmpoint", pointOverlay);

            //  var v = Android.OS.Environment.GetExternalStoragePublicDirectory ();
            //Internal projection string from the PRJ file. Note that the false easting value (x_0) has to be expressed in meter for proj4 string.
            string internalProjectionString = "+proj=utm +zone=37 +south +ellps=clrk80 +units=m +no_defs";

            proj4.InternalProjectionParametersString = internalProjectionString;
            //External projection string as Geodetic (21037).
            proj4.ExternalProjectionParametersString = ManagedProj4Projection.GetEpsgParametersString(21037);
            proj4.Open();

            shapeFileFeatureLayer.FeatureSource.Projection = proj4;
            buildingLayer.FeatureSource.Projection         = proj4;
            pointLayer.FeatureSource.Projection            = proj4;

            hLayer.RequireIndex                = false;
            buildingLayer.RequireIndex         = false;
            shapeFileFeatureLayer.RequireIndex = false;
            shapeFileFeatureLayer.Open();
            androidMap.MapDoubleTap += AndroidMap_MapDoubleTap;

            androidMap.CurrentExtent = shapeFileFeatureLayer.GetBoundingBox();
            shapeFileFeatureLayer.Close();
            proj4.Close();
            androidMap.Refresh();

            gpsButton       = GetButton(Resource.Drawable.Gps, TrackButtonClick);
            addButton       = GetButton(Resource.Drawable.Add, TrackButtonClick);
            searchButton    = GetButton(Resource.Drawable.Search, TrackButtonClick);
            cursorButton    = GetButton(Resource.Drawable.Cursor, TrackButtonClick);
            drawButton      = GetButton(Resource.Drawable.Draw, TrackButtonClick);
            pointButton     = GetButton(Resource.Drawable.Point, TrackButtonClick);
            lineButton      = GetButton(Resource.Drawable.Line, TrackButtonClick);
            rectangleButton = GetButton(Resource.Drawable.Rectangle, TrackButtonClick);
            circleButton    = GetButton(Resource.Drawable.Circle, TrackButtonClick);
            polygonButton   = GetButton(Resource.Drawable.Polygon, TrackButtonClick);
            ellipseButton   = GetButton(Resource.Drawable.Ellipse, TrackButtonClick);
            editButton      = GetButton(Resource.Drawable.Edit, TrackButtonClick);
            clearButton     = GetButton(Resource.Drawable.Clear, TrackButtonClick);

            trackLinearLayout             = new LinearLayout(this);
            trackLinearLayout.Orientation = Orientation.Horizontal;
            trackLinearLayout.Visibility  = ViewStates.Gone;
            trackLinearLayout.AddView(pointButton);
            trackLinearLayout.AddView(lineButton);
            trackLinearLayout.AddView(rectangleButton);
            trackLinearLayout.AddView(polygonButton);
            trackLinearLayout.AddView(ellipseButton);

            LinearLayout toolsLinearLayout = new LinearLayout(this);

            toolsLinearLayout.AddView(searchButton);
            toolsLinearLayout.AddView(addButton);
            toolsLinearLayout.AddView(gpsButton);
            toolsLinearLayout.AddView(cursorButton);
            toolsLinearLayout.AddView(drawButton);
            toolsLinearLayout.AddView(trackLinearLayout);
            toolsLinearLayout.AddView(editButton);
            toolsLinearLayout.AddView(clearButton);
            InitializeInstruction(toolsLinearLayout);
        }