protected virtual void SaveInternalProj4ProjectionParametersCore(FeatureLayer featureLayer, string proj4ProjectionParameters) { if (!string.IsNullOrEmpty(ExtensionFilter)) { var uri = GetUri(featureLayer); if (uri != null && uri.Scheme.Equals("file") && File.Exists(uri.LocalPath)) { string proj4PathFileName = uri.LocalPath; proj4PathFileName = Path.ChangeExtension(proj4PathFileName, ".prj"); string internalProj = Proj4Projection.ConvertProj4ToPrj(proj4ProjectionParameters); File.WriteAllText(proj4PathFileName, internalProj); } } }
public ProjectionWindow(string initializeProj4String, string descriptionText, string checkBoxContent) { proj4Parameters = initializeProj4String; InitializeComponent(); commonProjectionViewModel = commonProjection.DataContext as CommonProjectionViewModel; otherProjectionViewModel = otherProjection.DataContext as OtherProjectionViewModel; commonProjectionViewModel.SelectedProj4ProjectionParameters = initializeProj4String; viewModel = new ProjectionSelectionViewModel(descriptionText, checkBoxContent); DataContext = viewModel; Messenger.Default.Register <bool>(this, viewModel, (result) => { if (result) { string proj4ProjectionParameter = viewModel.SelectedProj4Parameter; var selectedOtherProjectionViewModel = viewModel.SelectedViewModel as OtherProjectionViewModel; if (selectedOtherProjectionViewModel != null && selectedOtherProjectionViewModel.SelectedProjectionType == SearchProjectionType.Custom) { proj4ProjectionParameter = viewModel.SelectedProj4Parameter; string projectionWkt = Proj4Projection.ConvertProj4ToPrj(proj4ProjectionParameter); if (!string.IsNullOrEmpty(projectionWkt)) { DialogResult = result; } else { System.Windows.Forms.MessageBox.Show(GisEditor.LanguageManager.GetStringResource("ProjectionSelectionWindowProj4InvalidText"), GisEditor.LanguageManager.GetStringResource("ProjectionSelectionWindowProj4InvalidCaption"), System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error); } } else { DialogResult = result; } SaveProjectionWindowStateToXml(); if (!string.IsNullOrEmpty(proj4ProjectionParameter)) { viewModel.SelectedProj4Parameter = proj4ProjectionParameter; } } else { DialogResult = result; } }); Closing += (s, e) => Messenger.Default.Unregister(this); HelpContainer.Content = GetHelpButton(); }
private static void SavePrjFile(string shapeFileName, string parameters) { string wkt = Proj4Projection.ConvertProj4ToPrj(parameters); string prjPath = Path.ChangeExtension(shapeFileName, "prj"); if (!File.Exists(prjPath)) { File.WriteAllText(prjPath, wkt); } else { File.Delete(prjPath); File.WriteAllText(prjPath, wkt); } }
private void Output(IEnumerable <Feature> bufferedFeatures, string path, string projection, bool dissolve = false) { string projectionInWKT = Proj4Projection.ConvertProj4ToPrj(projection); if (dissolve) { columns = new Collection <FeatureSourceColumn>(); columns.Add(new FeatureSourceColumn("OBJECTID", DbfColumnType.Character.ToString(), 1)); columns.Add(new FeatureSourceColumn("SHAPE", DbfColumnType.Character.ToString(), 12)); } FileExportInfo info = new FileExportInfo(bufferedFeatures, columns, path, projectionInWKT); Export(info); }
private void DisplayMap_Load(object sender, EventArgs e) { string convertResultFor4326 = Proj4Projection.ConvertEpsgToPrj(4326); winformsMap1.MapUnit = GeographyUnit.DecimalDegree; winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean); WorldMapKitWmsDesktopOverlay worldMapKitDesktopOverlay = new WorldMapKitWmsDesktopOverlay(); winformsMap1.Overlays.Add(worldMapKitDesktopOverlay); winformsMap1.CurrentExtent = new RectangleShape(-139.2, 92.4, 120.9, -93.2); winformsMap1.Refresh(); }
private Location ProjectLocation(Location location) { Proj4Projection prj4 = new Proj4Projection(); prj4.InternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString(); prj4.ExternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326); prj4.Open(); PointShape projectedPoint = prj4.ConvertToExternalProjection(new PointShape(location.Longitude, location.Latitude)) as PointShape; Location projectedLocation = new Location(); projectedLocation.Longitude = Math.Round(projectedPoint.X, 6); projectedLocation.Latitude = Math.Round(projectedPoint.Y, 6); return(projectedLocation); }
private static Feature ConvertToWgs84Projection(Feature feature, string displayProjectionParameters) { Feature featureInDecimalDegree = feature; Proj4Projection projection = new Proj4Projection(); projection.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326); projection.ExternalProjectionParametersString = displayProjectionParameters; SyncProjectionParametersString(projection); if (CanProject(projection)) { projection.Open(); featureInDecimalDegree = projection.ConvertToInternalProjection(featureInDecimalDegree); projection.Close(); } return(featureInDecimalDegree); }
private void InitializePlugin(MergeTaskPlugin plugin, List <FeatureSource> featureSources, FeatureSourceColumn[] columns) { if (OutputMode == OutputMode.ToFile) { plugin.OutputPathFileName = OutputPathFileName; } else { string tempPathFileName = Path.Combine(FolderHelper.GetCurrentProjectTaskResultFolder(), TempFileName) + ".shp"; plugin.OutputPathFileName = tempPathFileName; OutputPathFileName = tempPathFileName; } plugin.Wkt = Proj4Projection.ConvertProj4ToPrj(GisEditor.ActiveMap.DisplayProjectionParameters); plugin.FeatureSources = featureSources; plugin.Columns = columns; }
private static Feature ConvertToWgs84Projection(Feature feature) { Feature featureInDecimalDegree = feature; Proj4Projection projection = new Proj4Projection(); projection.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326); projection.ExternalProjectionParametersString = GisEditor.ActiveMap.DisplayProjectionParameters; projection.SyncProjectionParametersString(); if (projection.CanProject()) { projection.Open(); featureInDecimalDegree = projection.ConvertToInternalProjection(featureInDecimalDegree); projection.Close(); } return(featureInDecimalDegree); }
private void PrepareTaskParameters(BufferTaskPlugin plugin) { FeatureSource featureSource = null; if (CurrentLayerHasSelectedFeatures && OnlyBufferSelectedFeatures) { ShapeFileExporter shpExporter = new ShapeFileExporter(); string projectionInWKT = Proj4Projection.ConvertProj4ToPrj(GisEditor.ActiveMap.DisplayProjectionParameters); if (GisEditor.SelectionManager.GetSelectionOverlay() != null) { var features = GisEditor.SelectionManager.GetSelectionOverlay().HighlightFeatureLayer .InternalFeatures.Where(f => f.Tag == SelectedFeatureLayer); FileExportInfo info = new FileExportInfo(features, GetColumns(), tempShpFilePath, projectionInWKT); shpExporter.ExportToFile(info); } featureSource = new ShapeFileFeatureSource(tempShpFilePath); } else { featureSource = SelectedFeatureLayer.FeatureSource; } if (featureSource.IsOpen) { featureSource.Close(); } if (OutputMode == OutputMode.ToFile) { plugin.OutputPathFileName = OutputPathFileName; } else { string tempPathFileName = Path.Combine(FolderHelper.GetCurrentProjectTaskResultFolder(), TempFileName) + ".shp"; plugin.OutputPathFileName = tempPathFileName; OutputPathFileName = tempPathFileName; } plugin.FeatureSource = featureSource; plugin.Distance = Distance; plugin.Smoothness = Smoothness; plugin.Capstyle = CapStyle; plugin.MapUnit = GisEditor.ActiveMap.MapUnit; plugin.DistanceUnit = SelectedDistanceUnit; plugin.DisplayProjectionParameters = GisEditor.ActiveMap.DisplayProjectionParameters; plugin.Dissolve = NeedDissolve; }
private void InitializePlugin(ClipTaskPlugin plugin, List <FeatureLayer> clippingLayerFeatureLayers) { if (OutputMode == OutputMode.ToFile) { plugin.OutputPathFileName = OutputPathFileName; } else { string tempPathFileName = Path.Combine(FolderHelper.GetCurrentProjectTaskResultFolder(), TempFileName) + ".shp"; plugin.OutputPathFileName = tempPathFileName; OutputPathFileName = tempPathFileName; } plugin.MasterLayerFeatureLayer = MasterLayer; plugin.ClippingLayerFeatureLayers = clippingLayerFeatureLayers; plugin.Wkt = Proj4Projection.ConvertProj4ToPrj(GisEditor.ActiveMap.DisplayProjectionParameters); plugin.ClippingType = CurrentClippingType.ClippingType; }
private void InitializePlugin(DissolveTaskPlugin plugin, FeatureSource featureSource) { plugin.Wkt = Proj4Projection.ConvertProj4ToPrj(GisEditor.ActiveMap.DisplayProjectionParameters); plugin.MatchColumns = MatchColumns; plugin.OperatorPairs = OperatorPairs; plugin.FeatureSource = featureSource; if (OutputMode == OutputMode.ToFile) { plugin.OutputPathFileName = OutputPathFileName; } else { string tempPathFileName = Path.Combine(FolderHelper.GetCurrentProjectTaskResultFolder(), TempFileName) + ".shp"; plugin.OutputPathFileName = tempPathFileName; OutputPathFileName = tempPathFileName; } }
public void AnotherWFS(Map map) { WfsFeatureLayer wfs = new ThinkGeo.MapSuite.Layers.WfsFeatureLayer("https://demo.boundlessgeo.com/geoserver/wfs", "topp:states"); wfs.TimeoutInSeconds = 60; Proj4Projection proj4Projection = new Proj4Projection(4326, 4326); proj4Projection.Open(); wfs.FeatureSource.Projection = proj4Projection; wfs.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.SimpleColors.BrightRed, 15, false); wfs.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; LayerOverlay overlay = map.CustomOverlays["AnotherWFS"] as LayerOverlay; overlay.Layers.Clear(); overlay.Layers.Add(wfs); }
private void SaveFeaturesToTempFile() { string tempDir = Path.Combine(GisEditor.InfrastructureManager.TemporaryPath, TempPath); if (!Directory.Exists(tempDir)) { Directory.CreateDirectory(tempDir); } tempFilePath = Path.Combine(tempDir, "BlendTemp.shp"); List <Feature> featuresToBlend = null; if (BlendSelectedFeaturesOnly) { featuresToBlend = FilterSelectedFeatures(); } //rename the IDs, becaue features from different layers may have the same ID. //and the exporter can not export features that have the same IDs featuresToBlend = RenameFeatureIds(featuresToBlend); string projectionInWKT = Proj4Projection.ConvertProj4ToPrj(GisEditor.ActiveMap.DisplayProjectionParameters); var columns = ColumnsToInclude.Select(c => c.ToFeatureSourceColumn()).ToList(); if (IsIntersect) { tempFilesForIntersect = new List <string>(); var featureGroups = featuresToBlend.GroupBy(feature => feature.Tag).ToList(); foreach (var group in featureGroups) { string path = Path.Combine(tempDir, string.Format("BlendTemp{0}.shp", ((Layer)group.Key).Name)); tempFilesForIntersect.Add(path); FileExportInfo info = new FileExportInfo(group, columns, path, projectionInWKT); ShapeFileExporter exporter = new ShapeFileExporter(); exporter.ExportToFile(info); } } else { FileExportInfo info = new FileExportInfo(featuresToBlend, columns, tempFilePath, projectionInWKT); ShapeFileExporter exporter = new ShapeFileExporter(); exporter.ExportToFile(info); } }
private void InitializePlugin(SplitTaskPlugin plugin, FeatureSource featureSource, Dictionary <string, string> exportConfigs) { if (OutputMode == OutputMode.ToFile) { plugin.OutputPath = OutputPath; } else { plugin.OutputPath = FolderHelper.GetCurrentProjectTaskResultFolder(); OutputPath = plugin.OutputPath; } plugin.Wkt = Proj4Projection.ConvertProj4ToPrj(GisEditor.ActiveMap.DisplayProjectionParameters); plugin.FeatureSource = featureSource; plugin.SplitColumnName = SelectedFeatureSourceColumn.ColumnName; plugin.ExportConfigs = exportConfigs; plugin.LayerName = SelectedLayerToSplit.Name; plugin.OverwriteOutputFiles = OverwriteOutputFiles; }
private static Feature GetProjectedFeature(Feature feature) { Proj4Projection projection = new Proj4Projection(); projection.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326); projection.ExternalProjectionParametersString = GisEditor.ActiveMap.DisplayProjectionParameters; projection.SyncProjectionParametersString(); Feature tmpFeature = new Feature(feature.GetWellKnownBinary()); if (projection.CanProject()) { projection.Open(); tmpFeature = projection.ConvertToInternalProjection(tmpFeature); projection.Close(); } return(tmpFeature); }
public static Proj4ProjectionInfo CreateInstance(Projection projection) { Proj4Projection unManagedProjection = projection as Proj4Projection; Proj4Projection managedProjection = projection as Proj4Projection; if (unManagedProjection != null) { return(new UnManagedProj4ProjectionInfo(unManagedProjection)); } else if (managedProjection != null) { return(new ManagedProj4ProjectionInfo(managedProjection)); } else { return(null); } }
private void BufferShapeFile() { var args = new UpdatingTaskProgressEventArgs(TaskState.Updating); var currentSource = (ShapeFileFeatureSource)FeatureSource; if (!currentSource.IsOpen) { currentSource.Open(); } var canceled = false; var projectionWkt = Proj4Projection.ConvertProj4ToPrj(DisplayProjectionParameters); var helper = new ShapeFileHelper(ShapeFileType.Polygon, outputPathFileName, currentSource.GetColumns(), projectionWkt); helper.CapabilityToFlush = 1000; helper.ForEachFeatures(currentSource, (f, currentProgress, upperBound, percentage) => { try { if (f.GetWellKnownBinary() != null) { //Feature bufferedFeature = f.Buffer(Distance, Smoothness, Capstyle, MapUnit, DistanceUnit); //Feature bufferedFeature = SqlTypesGeometryHelper.Buffer(f, Distance, Smoothness, Capstyle, MapUnit, DistanceUnit); Feature bufferedFeature = BufferFeature(f); helper.Add(bufferedFeature); } args = new UpdatingTaskProgressEventArgs(TaskState.Updating, percentage); args.Current = currentProgress; args.UpperBound = upperBound; OnUpdatingProgress(args); canceled = args.TaskState == TaskState.Canceled; return(canceled); } catch (Exception ex) { GisEditor.LoggerManager.Log(LoggerLevel.Debug, ex.Message, new ExceptionInfo(ex)); return(false); } }); helper.Commit(); }
private void SaveSelectedFeaturesToTempFile() { string tempDir = Path.Combine(GisEditor.InfrastructureManager.TemporaryPath, TempPath); if (!Directory.Exists(tempDir)) { Directory.CreateDirectory(tempDir); } tempFilePath = Path.Combine(tempDir, "SplitTemp.shp"); var selectedFeatures = HighlightFeatureLayer.InternalFeatures.Where(f => f.Tag == SelectedLayerToSplit); string projectionInWKT = Proj4Projection.ConvertProj4ToPrj(GisEditor.ActiveMap.DisplayProjectionParameters); FileExportInfo info = new FileExportInfo(selectedFeatures, ColumnsInSelectedLayer, tempFilePath, projectionInWKT); ShapeFileExporter exporter = new ShapeFileExporter(); exporter.ExportToFile(info); }
// Here we need keep the FeatureSourceColumn. // It will be used in two places. // 1, used to export, it we need convert it into intermediate column and create it. // 2, used to create, the columns will be exactly column type. // so in the CreateFeatureLayer method, we need to first see if the column is IntermediateColumn // , if it is, we use it, or else use the one on the featuresource. public ConfigureFeatureLayerParameters(Uri layerUri, IEnumerable <FeatureSourceColumn> featureSourceColumns) { this.layerUri = layerUri; this.customData = new Dictionary <string, object>(); this.memoColumnConvertMode = MemoColumnConvertMode.None; this.longColumnTruncateMode = LongColumnTruncateMode.None; this.proj4ProjectionParametersString = Proj4Projection.GetDecimalDegreesParametersString(); this.addedFeatures = new Collection <Feature>(); this.updatedFeatures = new Dictionary <string, Feature>(); this.deletedFeatures = new Collection <Feature>(); this.addedColumns = new Collection <FeatureSourceColumn>(); this.updatedColumns = new Dictionary <string, FeatureSourceColumn>(); this.deletedColumns = new Collection <FeatureSourceColumn>(); foreach (var column in featureSourceColumns) { this.addedColumns.Add(column); } }
private void SaveSelectedFeaturesToTempFile() { string tempDir = Path.Combine(GisEditor.InfrastructureManager.TemporaryPath, TempPath); if (!Directory.Exists(tempDir)) { Directory.CreateDirectory(tempDir); } tempFilePath = Path.Combine(tempDir, "DissolveTemp.shp"); Collection <Feature> featuresToDissolve = GetFeaturesToDissolve(); string projectionInWKT = Proj4Projection.ConvertProj4ToPrj(GisEditor.ActiveMap.DisplayProjectionParameters); FileExportInfo info = new FileExportInfo(featuresToDissolve, GetColumnsOfSelectedLayer(), tempFilePath, projectionInWKT); ShapeFileExporter exporter = new ShapeFileExporter(); exporter.ExportToFile(info); }
public static void Hammer() { double prjX = -12756274.0; double prjY = 6378137.0; //prjX = -12756849.0; //prjY = 6379251.5; double[] xs = new double[] { prjX }; double[] ys = new double[] { prjY }; Proj4Projection _srcProjection = new Proj4Projection("+proj=latlong +datum=WGS84 +a=6378137 +ellps=WGS84 +towgs84=0,0,0"); Proj4Projection _dstProjection = new Proj4Projection("+proj=hammer +lat_0=0 +lon_0=105 +x_0=0 +y_0=0 +datum=WGS84 +a=6378137 +ellps=WGS84 +towgs84=0,0,0"); Proj4Projection.Transform(_dstProjection, _srcProjection, xs, ys); //IProjectionTransform tr = ProjectionTransformFactory.GetProjectionTransform(new //_projectionTransform.InverTransform(xs, ys); double geoX = xs[0]; double geoY = ys[0]; }
private void InitializePlugin(SimplifyTaskPlugin plugin, FeatureSource featureSource) { if (OutputMode == OutputMode.ToFile) { plugin.OutputPathFileName = OutputPathFileName; } else { string tempPathFileName = Path.Combine(FolderHelper.GetCurrentProjectTaskResultFolder(), TempFileName) + ".shp"; plugin.OutputPathFileName = tempPathFileName; OutputPathFileName = tempPathFileName; } plugin.FeatureSource = featureSource; plugin.PreserveTopology = PreserveTopology; plugin.SelectedDistanceUnit = SelectedDistanceUnit; plugin.SimplificationTolerance = SimplificationTolerance; plugin.MapUnit = GisEditor.ActiveMap.MapUnit; plugin.DisplayProjectionParameters = Proj4Projection.ConvertProj4ToPrj(GisEditor.ActiveMap.DisplayProjectionParameters); }
private void winformsMap1_MouseMove(object sender, MouseEventArgs e) { //Displays the X and Y in screen coordinates. statusStrip1.Items["toolStripStatusLabelScreen"].Text = "X:" + e.X + " Y:" + e.Y; //Gets the PointShape in world coordinates from screen coordinates. PointShape pointShape = ExtentHelper.ToWorldCoordinate(winformsMap1.CurrentExtent, new ScreenPointF(e.X, e.Y), winformsMap1.Width, winformsMap1.Height); Proj4Projection proj4 = new Proj4Projection(); proj4.InternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString(); proj4.ExternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326); proj4.Open(); PointShape projPointShape = (PointShape)proj4.ConvertToExternalProjection(pointShape); proj4.Close(); //Displays world coordinates in decimal degrees from the OSM Mercator projection statusStrip1.Items["toolStripStatusLabelWorld"].Text = "(world) X:" + Math.Round(projPointShape.X, 4) + " Y:" + Math.Round(projPointShape.Y, 4); }
private void FilterEarthquake() { FilteredQueryResults.Clear(); Proj4Projection mercatorToWgs84Projection = new Proj4Projection(); mercatorToWgs84Projection.InternalProjectionParametersString = Proj4Projection.GetSphericalMercatorParametersString(); mercatorToWgs84Projection.ExternalProjectionParametersString = Proj4Projection.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)); }
private void SaveClippingLayer() { string tempDir = Path.Combine(GisEditor.InfrastructureManager.TemporaryPath, TempPath); if (!Directory.Exists(tempDir)) { Directory.CreateDirectory(tempDir); } clippingLayerTempPath = Path.Combine(tempDir, "ClippingTemp.shp"); Collection <Feature> clippingFeatures = null; var clipLayers = this.ClippingLayers.Where(l => l.IsSelected).Select(l => l.FeatureLayer); if (this.IsUseSelectedFeatures) { Collection <Feature> selectedFeatures = new Collection <Feature>(); var selectionOverlay = GisEditor.SelectionManager.GetSelectionOverlay(); if (selectionOverlay != null) { var selectedFeaturesInThisLayer = selectionOverlay.HighlightFeatureLayer.InternalFeatures.Where(tmpFeature => clipLayers.Contains(tmpFeature.Tag)); foreach (var feature in selectedFeaturesInThisLayer) { selectedFeatures.Add(feature); } } if (selectedFeatures.Count > 0) { clippingFeatures = selectedFeatures; } } //we don't need columns from the clipping layers string projectionInWKT = Proj4Projection.ConvertProj4ToPrj(GisEditor.ActiveMap.DisplayProjectionParameters); FileExportInfo info = new FileExportInfo(clippingFeatures, new FeatureSourceColumn[] { new FeatureSourceColumn("None", "String", 10) }, clippingLayerTempPath, projectionInWKT); ShapeFileExporter exporter = new ShapeFileExporter(); exporter.ExportToFile(info); }
public void WFS(Map map) { //("https://demo.boundlessgeo.com/geoserver/wfs", "medford:bikelanes") var wfs = new WfsFeatureLayer("https://geoservices.informatievlaanderen.be/overdrachtdiensten/GRB/wfs", "GRB:WLAS"); wfs.TimeoutInSeconds = 600; Proj4Projection proj4Projection = new Proj4Projection(31370, 4326); proj4Projection.Open(); wfs.FeatureSource.Projection = proj4Projection; wfs.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = LineStyles.CreateSimpleLineStyle(GeoColor.SimpleColors.BrightRed, 15, false); wfs.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; //do all events LayerOverlay overlay = map.CustomOverlays["SomeWFS"] as LayerOverlay; overlay.Layers.Clear(); overlay.Layers.Add(wfs); }
private static void Reproject() { var result = System.Windows.Forms.MessageBox.Show("Warning! This will modify the internal projection information of your layer. This should only be done if the wrong projection information was selected when initially loading the layer.\r\n\r\nTo change the map's display projection, please use the Map Projection button on the Home tab of the ribbon bar.", "Warning", System.Windows.Forms.MessageBoxButtons.OKCancel, System.Windows.Forms.MessageBoxIcon.Warning); if (result == System.Windows.Forms.DialogResult.OK) { if (GisEditor.LayerListManager.SelectedLayerListItem == null) { return; } FeatureLayer layer = GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as FeatureLayer; if (layer != null) { bool overSized = IsLayerOverSized(layer); if (overSized) { string reprojectShapeFileNotification = "Applying a projection for this layer may affect performance. Please use the \"Reprojection Wizard\" in the \"Tools\" tab to reproject the ShapeFile to gain better performance."; System.Windows.Forms.MessageBox.Show(reprojectShapeFileNotification, "Info", System.Windows.Forms.MessageBoxButtons.OK); } string initProj4String = GetActiveLayersProj4ProjectionParameter(); var description = GisEditor.LanguageManager.GetStringResource("SelectAProjectionForSingleLayerDescription"); ProjectionWindow proj4Window = new ProjectionWindow(initProj4String, description, ""); if (proj4Window.ShowDialog().GetValueOrDefault()) { if (!string.IsNullOrEmpty(proj4Window.Proj4ProjectionParameters)) { var projection = new Proj4Projection(proj4Window.Proj4ProjectionParameters, GisEditor.ActiveMap.DisplayProjectionParameters); projection.SyncProjectionParametersString(); projection.Open(); layer.FeatureSource.Projection = projection; ClearCache(layer); GisEditor.ActiveMap.Refresh(); } } } } }
protected override TaskPlugin GetTaskPluginCore() { ExportTaskPlugin exportTaskPlugin = new ExportTaskPlugin(); exportTaskPlugin.NeedConvertMemoToCharacter = NeedConvertMemoToCharacter; if (OutputMode == OutputMode.ToFile) { exportTaskPlugin.OutputPathFileName = OutputPathFileName; } else { string tempPathFileName = Path.Combine(FolderHelper.GetCurrentProjectTaskResultFolder(), TempFileName) + ".shp"; exportTaskPlugin.OutputPathFileName = tempPathFileName; OutputPathFileName = tempPathFileName; } exportTaskPlugin.ProjectionWkt = Proj4Projection.ConvertProj4ToPrj(ProjectionParameter); exportTaskPlugin.InternalPrj4Projection = GisEditor.ActiveMap.DisplayProjectionParameters; switch (ExportMode) { case ExportMode.ExportMeasuredFeatures: FillMeasuredFeatures(exportTaskPlugin.FeaturesForExporting, exportTaskPlugin.FeatureSourceColumns); break; case ExportMode.ExportSelectedFeatures: default: foreach (var entry in this.ColumnEntities) { if (entry.IsChecked) { exportTaskPlugin.FeatureSourceColumns.Add(new FeatureSourceColumn(entry.ColumnName, entry.ColumnType, entry.MaxLength)); exportTaskPlugin.CostomizedColumnNames[entry.ColumnName] = entry.EditedColumnName; } } FillSelectedFeatures(exportTaskPlugin.FeatureIdsForExporting); exportTaskPlugin.FeatureLayer = SelectedFeatureLayer; break; } return(exportTaskPlugin); }
public static string GetFormattedWorldCoordinate(this GisEditorWpfMap map, ScreenPointF screenPoint, MouseCoordinateType mouseCoordinateType) { PointShape lonlat = map.ToWorldCoordinate(screenPoint.X, screenPoint.Y); double xInCurrentProjection = lonlat.X; double yInCurrentProjection = lonlat.Y; string projectionFullName = "Unknown"; if (map.DisplayProjectionParameters != null) { string projectionShortName = map.DisplayProjectionParameters.Split(' ')[0].Replace("+proj=", string.Empty); projectionFullName = projectionAbbreviations[projectionShortName]; } GeographyUnit mapUnit = GisEditorWpfMap.GetGeographyUnit(map.DisplayProjectionParameters); if (projectionFullName == "Unknown" && mapUnit == GeographyUnit.Unknown) { return(String.Format("X:{0}, Y:{1}", lonlat.X.ToString("N4", CultureInfo.InvariantCulture), lonlat.Y.ToString("N4", CultureInfo.InvariantCulture))); } else { if (mapUnit != GeographyUnit.DecimalDegree) { try { Proj4Projection proj = new Proj4Projection(); proj.InternalProjectionParametersString = map.DisplayProjectionParameters; proj.ExternalProjectionParametersString = Proj4Projection.GetDecimalDegreesParametersString(); proj.Open(); lonlat = proj.ConvertToExternalProjection(lonlat) as PointShape; proj.Close(); } catch { lonlat = new PointShape(); } } return(GetMouseCoordinates(lonlat.X, lonlat.Y, mouseCoordinateType, map.DisplayProjectionParameters, xInCurrentProjection, yInCurrentProjection)); } }