public PopupUserControl(Feature feature)
        {
            InitializeComponent();

            string speed = feature.ColumnValues["Speed"];
            string name = feature.ColumnValues["VehicleName"];
            string latitude = feature.ColumnValues["Latitude"];
            string dateTime = feature.ColumnValues["DateTime"];
            string longitude = feature.ColumnValues["Longitude"];

            txtName.Text = name;
            double x, y;
            if (double.TryParse(longitude, out x) && double.TryParse(latitude, out y))
            {
                ManagedProj4Projection proj4 = new ManagedProj4Projection();
                proj4.InternalProjectionParametersString = Proj4Projection.GetDecimalDegreesParametersString();
                proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();
                proj4.Open();

                Vertex vertex = proj4.ConvertToInternalProjection(x, y);
                txtLongitude.Text = vertex.X.ToString("N6", CultureInfo.InvariantCulture);
                txtLatitude.Text = vertex.Y.ToString("N6", CultureInfo.InvariantCulture);

                proj4.Close();
            }
            else
            {
                txtLongitude.Text = longitude;
                txtLatitude.Text = latitude;
            }

            txtSpeed.Text = speed + " mph";
            txtTime.Text = dateTime;
        }
Example #2
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);
        }
        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));
        }
Example #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);
        }