public void OnEvent(object element, object dataset) { if (!(element is IFeatureLayer) || !(((IFeatureLayer)element).Class is IFeatureClass)) { return; } ExportFeatureClassDialog dlg = new ExportFeatureClassDialog( ((_doc != null && _doc.FocusMap != null) ? _doc.FocusMap.Display : null), element as IFeatureLayer); if (dlg.ShowDialog() == DialogResult.OK) { IDatasetElement destElement = dlg.DestinationDatasetElement; if (destElement != null && destElement.Class != null) { if (MessageBox.Show("Add new feature class to map?", "Add", MessageBoxButtons.YesNo) == DialogResult.Yes) { ILayer layer = LayerFactory.Create(destElement.Class); _doc.FocusMap.AddLayer(layer, 0); if (_doc.Application is IMapApplication) { ((IMapApplication)_doc.Application).RefreshActiveMap(DrawPhase.All); } } } } }
public object Clone() { GeoServicesClass clone = new GeoServicesClass(_dataset); clone._clonedThemes = new List <IWebServiceTheme>(); var themes = (_clonedThemes != null) ? _clonedThemes : (_dataset?._themes ?? new List <IWebServiceTheme>()); foreach (IWebServiceTheme theme in themes) { if (theme == null || theme.Class == null) { continue; } clone._clonedThemes.Add(LayerFactory.Create( theme.Class, theme as ILayer, clone) as IWebServiceTheme); } clone.BeforeMapRequest = BeforeMapRequest; clone.AfterMapRequest = AfterMapRequest; clone.ModifyResponseOuput = ModifyResponseOuput; return(clone); }
private void AddDataset(IDataset dataset) { if (dataset == null || dataset.Elements == null) { return; } if (dataset.State != DatasetState.opened) { if (!dataset.Open()) { MessageBox.Show("Can't open dataset '" + dataset.DatasetName + "'.\n" + dataset.lastErrorMsg); return; } } foreach (IDatasetElement element in dataset.Elements) { if (element == null) { continue; } ILayer layer = LayerFactory.Create(element.Class); dgLayers.Rows.Add(new object[] { true, element.Title, true }); _elements.Add(new DatasetItemElement(dataset, layer)); } }
public Task <IDatasetElement> Element(string title) { if (_fc != null) { return(Task.FromResult <IDatasetElement>(LayerFactory.Create(_fc))); } return(Task.FromResult <IDatasetElement>(null)); }
public Task <List <IDatasetElement> > Elements() { List <IDatasetElement> elements = new List <IDatasetElement>(); if (_fc != null) { elements.Add(LayerFactory.Create(_fc)); } return(Task.FromResult(elements)); }
public IDatasetElement this[string title] { get { if (_fc != null) { return(LayerFactory.Create(_fc)); } return(null); } }
public void OnEvent(object element, object dataset) { if (!(element is IDatasetElement) || !(dataset is IDataset)) { return; } TOC toc = _doc.FocusMap.TOC as TOC; if (toc == null) { return; } ITOCElement tocElement = toc.GetTOCElement(((IDatasetElement)element).Class); if (tocElement == null) { return; } ILayer newLayer = LayerFactory.Create(((IDatasetElement)element).Class); if (newLayer is IFeatureLayer && element is IFeatureLayer) { if (((IFeatureLayer)element).Joins != null) { ((IFeatureLayer)newLayer).Joins = ((IFeatureLayer)element).Joins.Clone() as FeatureLayerJoins; } if (((IFeatureLayer)element).FilterQuery != null) { QueryFilter filter = new QueryFilter(); filter.WhereClause = ((IFeatureLayer)element).FilterQuery.WhereClause; ((IFeatureLayer)newLayer).FilterQuery = filter; } } if (newLayer == null) { return; } _doc.FocusMap.AddLayer(newLayer); if (_doc.Application is IMapApplication) { ((IMapApplication)_doc.Application).RefreshActiveMap(Framework.Carto.DrawPhase.All); } }
public object Clone() { MapServerClass clone = new MapServerClass(_dataset); clone._clonedThemes = new List <IWebServiceTheme>(); foreach (IWebServiceTheme theme in Themes) { if (theme == null || theme.Class == null) { continue; } clone._clonedThemes.Add(LayerFactory.Create(theme.Class, theme as ILayer, clone) as IWebServiceTheme); } clone.AfterMapRequest = AfterMapRequest; return(clone); }
public void OnEvent(object MapEvent) { FormGeoProcessor dlg = (_doc != null && _doc.FocusMap != null) ? new FormGeoProcessor(_doc.FocusMap.MapElements) : new FormGeoProcessor(); dlg.ShowInTaskbar = false; if (dlg.ShowDialog() == DialogResult.OK) { IActivity activity = dlg.Activity; if (activity != null) { Thread thread = new Thread(new ParameterizedThreadStart(StartProgress)); IProgressDialog progress = ProgressDialog.CreateProgressDialogInstance(); progress.ShowProgressDialog(activity, activity, thread); if (_datas != null && _doc != null && _doc.FocusMap != null) { if (MessageBox.Show("Add new feature class to map?", "Add", MessageBoxButtons.YesNo) == DialogResult.Yes) { foreach (IActivityData data in _datas) { if (data == null || data.Data == null || data.Data.Class == null) { continue; } ILayer layer = LayerFactory.Create(data.Data.Class); _doc.FocusMap.AddLayer(layer, 0); } } if (_doc.Application is IMapApplication) { ((IMapApplication)_doc.Application).RefreshActiveMap(DrawPhase.All); } } } } }
async public Task <bool> Open(IServiceRequestContext context) { if (_class == null) { _class = new ArcIMSClass(this); } string server = ConfigTextStream.ExtractValue(ConnectionString, "server"); string service = ConfigTextStream.ExtractValue(ConnectionString, "service"); string user = ConfigTextStream.ExtractValue(ConnectionString, "user"); string pwd = ConfigTextStream.ExtractValue(ConnectionString, "pwd"); //if ((user == "#" || user == "$") && // context != null && context.ServiceRequest != null && context.ServiceRequest.Identity != null) //{ // string roles = String.Empty; // if (user == "#" && context.ServiceRequest.Identity.UserRoles != null) // { // foreach (string role in context.ServiceRequest.Identity.UserRoles) // { // if (String.IsNullOrEmpty(role)) continue; // roles += "|" + role; // } // } // user = context.ServiceRequest.Identity.UserName + roles; // pwd = context.ServiceRequest.Identity.HashedPassword; //} dotNETConnector connector = new dotNETConnector(); if (!String.IsNullOrEmpty(user) || !String.IsNullOrEmpty(pwd)) { connector.setAuthentification(user, pwd); } try { _themes.Clear(); string axl = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ARCXML version=\"1.1\"><REQUEST><GET_SERVICE_INFO fields=\"true\" envelope=\"true\" renderer=\"true\" extensions=\"true\" /></REQUEST></ARCXML>"; //string axl = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ARCXML version=\"1.1\"><REQUEST><GET_SERVICE_INFO dpi=\"96\" toc=\"true\" /></REQUEST></ARCXML>"; await ArcIMSClass.LogAsync(context, "GetServiceInfo Response", server, service, axl); axl = connector.SendRequest(axl, server, service); await ArcIMSClass.LogAsync(context, "GetServiceInfo Response", server, service, axl); XmlDocument doc = new XmlDocument(); doc.LoadXml(axl); double dpi = 96.0; XmlNode screen = doc.SelectSingleNode("//ENVIRONMENT/SCREEN"); if (screen != null) { if (screen.Attributes["dpi"] != null) { dpi = Convert.ToDouble(screen.Attributes["dpi"].Value.Replace(".", ",")); } } double dpm = (dpi / 0.0254); XmlNode FeatureCoordSysNode = doc.SelectSingleNode("ARCXML/RESPONSE/SERVICEINFO/PROPERTIES/FEATURECOORDSYS"); _sRef = ArcXMLGeometry.AXL2SpatialReference(FeatureCoordSysNode); foreach (XmlNode envelopeNode in doc.SelectNodes("//ENVELOPE")) { if (_envelope == null) { _envelope = new Envelope(envelopeNode); } else { _envelope.Union(new Envelope(envelopeNode)); } } foreach (XmlNode layerNode in doc.SelectNodes("//LAYERINFO[@id]")) { bool visible = true; if (layerNode.Attributes["visible"] != null) { bool.TryParse(layerNode.Attributes["visible"].Value, out visible); } XmlNode tocNode = layerNode.SelectSingleNode("TOC"); if (tocNode != null) { ReadTocNode(tocNode); } IClass themeClass = null; IWebServiceTheme theme; if (layerNode.Attributes["type"] != null && layerNode.Attributes["type"].Value == "featureclass") { themeClass = await ArcIMSThemeFeatureClass.CreateAsync(this, layerNode.Attributes["id"].Value); ((ArcIMSThemeFeatureClass)themeClass).Name = layerNode.Attributes["name"] != null ? layerNode.Attributes["name"].Value : layerNode.Attributes["id"].Value; ((ArcIMSThemeFeatureClass)themeClass).fieldsFromAXL = layerNode.InnerXml; ((ArcIMSThemeFeatureClass)themeClass).SpatialReference = _sRef; XmlNode FCLASS = layerNode.SelectSingleNode("FCLASS[@type]"); if (FCLASS != null) { ((ArcIMSThemeFeatureClass)themeClass).fClassTypeString = FCLASS.Attributes["type"].Value; } foreach (XmlNode child in layerNode.ChildNodes) { switch (child.Name) { case "SIMPLERENDERER": case "SIMPLELABELRENDERER": case "VALUEMAPRENDERER": case "SCALEDEPENDENTRENDERER": case "VALUEMAPLABELRENDERER": case "GROUPRENDERER": ((ArcIMSThemeFeatureClass)themeClass).OriginalRendererNode = child; break; } } theme = LayerFactory.Create(themeClass, _class as IWebServiceClass) as IWebServiceTheme; if (theme == null) { continue; } theme.Visible = visible; } else if (layerNode.Attributes["type"] != null && layerNode.Attributes["type"].Value == "image") { //themeClass = new ArcIMSThemeRasterClass(this, // layerNode.Attributes["name"] != null ? layerNode.Attributes["name"].Value : layerNode.Attributes["id"].Value); themeClass = new ArcIMSThemeRasterClass(this, layerNode.Attributes["id"].Value); ((ArcIMSThemeRasterClass)themeClass).Name = layerNode.Attributes["name"] != null ? layerNode.Attributes["name"].Value : layerNode.Attributes["id"].Value; theme = new WebServiceTheme( themeClass, themeClass.Name, layerNode.Attributes["id"].Value, visible, _class as IWebServiceClass); } else { continue; } try { if (layerNode.Attributes["minscale"] != null) { theme.MinimumScale = Convert.ToDouble(layerNode.Attributes["minscale"].Value.Replace(".", ",")) * dpm; } if (layerNode.Attributes["maxscale"] != null) { theme.MaximumScale = Convert.ToDouble(layerNode.Attributes["maxscale"].Value.Replace(".", ",")) * dpm; } } catch { } _themes.Add(theme); } _state = DatasetState.opened; ((ArcIMSClass)_class).SpatialReference = await this.GetSpatialReference(); return(true); } catch (Exception ex) { _state = DatasetState.unknown; _errMsg = ex.Message; await ArcIMSClass.ErrorLog(context, "Open Dataset", server, service, ex); return(false); } }
internal static IMap LoadMap(string name, IServiceRequestContext context) { try { DirectoryInfo di = new DirectoryInfo(ServicesPath); if (!di.Exists) { di.Create(); } FileInfo fi = new FileInfo(ServicesPath + @"\" + name + ".mxl"); if (fi.Exists) { ServerMapDocument doc = new ServerMapDocument(); doc.LoadMapDocument(fi.FullName); if (doc.Maps.Count == 1) { ApplyMetadata(doc.Maps[0] as Map); if (!mapDocument.AddMap(doc.Maps[0])) { return(null); } return(doc.Maps[0]); } return(null); } fi = new FileInfo(ServicesPath + @"\" + name + ".svc"); if (fi.Exists) { XmlStream stream = new XmlStream(""); stream.ReadStream(fi.FullName); IServiceableDataset sds = stream.Load("IServiceableDataset", null) as IServiceableDataset; if (sds != null && sds.Datasets != null) { Map map = new Map(); map.Name = name; foreach (IDataset dataset in sds.Datasets) { if (dataset is IRequestDependentDataset) { if (!((IRequestDependentDataset)dataset).Open(context)) { return(null); } } else { if (!dataset.Open()) { return(null); } } //map.AddDataset(dataset, 0); foreach (IDatasetElement element in dataset.Elements) { if (element == null) { continue; } ILayer layer = LayerFactory.Create(element.Class, element as ILayer); if (layer == null) { continue; } map.AddLayer(layer); if (element.Class is IWebServiceClass) { if (map.SpatialReference == null) { map.SpatialReference = ((IWebServiceClass)element.Class).SpatialReference; } foreach (IWebServiceTheme theme in ((IWebServiceClass)element.Class).Themes) { map.SetNewLayerID(theme); } } else if (element.Class is IFeatureClass && map.SpatialReference == null) { map.SpatialReference = ((IFeatureClass)element.Class).SpatialReference; } else if (element.Class is IRasterClass && map.SpatialReference == null) { map.SpatialReference = ((IRasterClass)element.Class).SpatialReference; } } } ApplyMetadata(map); if (!mapDocument.AddMap(map)) { return(null); } return(map); } return(null); } } catch (Exception ex) { if (Functions.log_errors) { Logger.Log(loggingMethod.error, "LoadConfig: " + ex.Message); } } return(null); }
private void Run() { if (_targetDataset == null || _fdb == null || _sourceDataset == null) { return; } //if (_targetDataset[_name] != null) //{ // MessageBox.Show("Featureclass '" + _name + "' already exists!"); // return; //} bool succeeded = false; try { Envelope bounds = new Envelope(_spatialIndexDef.SpatialIndexBounds); Envelope iBounds = new Envelope(bounds.minx - _tileSizeX, bounds.miny - _tileSizeY, bounds.maxx + _tileSizeX, bounds.maxy + _tileSizeY); _cacheDirectory += @"\" + _name; if (!String.IsNullOrEmpty(_cacheDirectory)) { DirectoryInfo di = new DirectoryInfo(_cacheDirectory); if (!di.Exists) { di.Create(); } StringBuilder sb = new StringBuilder(); sb.Append("<TileCacheDefinition>\r\n"); sb.Append(" <General levels='" + _levels + "' origin='lowerleft' />\r\n"); sb.Append(" <Envelope minx='" + bounds.minx.ToString(_nhi) + "' miny='" + bounds.miny.ToString(_nhi) + "' maxx='" + bounds.maxx.ToString(_nhi) + "' maxy='" + bounds.maxy.ToString(_nhi) + "' />\r\n"); sb.Append(" <TileSize x='" + _tileSizeX.ToString(_nhi) + "' y='" + _tileSizeY.ToString(_nhi) + "' />\r\n"); sb.Append(" <TileResolution x='" + _resX.ToString(_nhi) + "' y='" + _resY.ToString(_nhi) + "' />\r\n"); sb.Append("</TileCacheDefinition>"); StreamWriter sw = new StreamWriter(di.FullName + @"\tilecache.xml"); sw.WriteLine(sb.ToString()); sw.Close(); } ProgressReport report = new ProgressReport(); int datasetId = _fdb.DatasetID(_targetDataset.DatasetName); if (datasetId == -1) { return; } IClass cls = null; try { cls = _sourceDataset.Elements[0].Class; } catch { cls = null; } IMultiGridIdentify gridClass = cls as IMultiGridIdentify; if (_gridType == TileGridType.binary_float && gridClass == null) { return; } IFeatureClass sourceFc = cls as IFeatureClass; Map map = null; if (_gridType == TileGridType.image_jpg || _gridType == TileGridType.image_png) { map = new Map(); ILayer layer = LayerFactory.Create(cls); map.AddLayer(layer); //map.iWidth = (int)(_tileSizeX / _resX); //map.iHeight = (int)(_tileSizeY / _resY); } #region Create Featureclass IFeatureClass fc = null; IDatasetElement element = _targetDataset[_name]; if (element != null && element.Class is IFeatureClass) { fc = (IFeatureClass)element.Class; if (fc.GeometryType == geometryType.Polygon && fc.FindField("GRID_LEVEL") != null && fc.FindField("GRID_ROW") != null && fc.FindField("GRID_COLUMN") != null && fc.FindField("FILE") != null) { if (MessageBox.Show("TileGridClass already exists. Do you wan't to append to this Grid?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) != DialogResult.Yes) { return; } } else { _fdb.DeleteFeatureClass(_name); fc = null; } } if (fc == null) { Fields fields = new Fields(); fields.Add(new Field("GRID_LEVEL", FieldType.integer)); fields.Add(new Field("GRID_ROW", FieldType.integer)); fields.Add(new Field("GRID_COLUMN", FieldType.integer)); fields.Add(new Field("FILE", FieldType.String, 512)); _fdb.CreateFeatureClass(_targetDataset.DatasetName, _name, new GeometryDef(geometryType.Polygon), fields); element = _targetDataset[_name]; if (element == null || !(element.Class is IFeatureClass)) { return; } _fdb.SetSpatialIndexBounds(_name, "BinaryTree2", iBounds, _spatialIndexDef.SplitRatio, _spatialIndexDef.MaxPerNode, _spatialIndexDef.Levels); fc = (IFeatureClass)element.Class; } #endregion #region Create Tiles #region Report double tx = _tileSizeX, ty = _tileSizeY; if (ReportProgress != null) { report.featureMax = 0; for (int i = 0; i < _levels; i++) { if (_createLevels.Contains(i)) { for (double y = bounds.miny; y < bounds.maxy; y += ty) { for (double x = bounds.minx; x < bounds.maxx; x += tx) { report.featureMax++; } } } if (_levelType == TileLevelType.ConstantImagesize) { tx *= 2; ty *= 2; } } report.Message = "Create Tiles"; report.featurePos = 0; ReportProgress(report); } int reportInterval = (_createTiles ? 10 : 1000); #endregion List <IFeature> features = new List <IFeature>(); for (int level = 0; level < _levels; level++) { if (map != null) { map.iWidth = (int)(_tileSizeX / _resX); map.iHeight = (int)(_tileSizeY / _resY); } if (_createLevels.Contains(level)) { int row = 0; for (double y = bounds.miny; y < bounds.maxy; y += _tileSizeY) { DirectoryInfo di = new DirectoryInfo(_cacheDirectory + @"\" + level + @"\" + row); if (!di.Exists) { di.Create(); } int column = 0; for (double x = bounds.minx; x < bounds.maxx; x += _tileSizeX) { #region Polygon Polygon polygon = new Polygon(); Ring ring = new Ring(); ring.AddPoint(new Point(x, y)); ring.AddPoint(new Point(Math.Min(x + _tileSizeX, bounds.maxx), y)); ring.AddPoint(new Point(Math.Min(x + _tileSizeX, bounds.maxx), Math.Min(y + _tileSizeY, bounds.maxy))); ring.AddPoint(new Point(x, Math.Min(y + _tileSizeY, bounds.maxy))); ring.Close(); polygon.AddRing(ring); #endregion if (sourceFc != null) { SpatialFilter filter = new SpatialFilter(); filter.AddField(sourceFc.IDFieldName); filter.Geometry = polygon; filter.FilterSpatialReference = fc.SpatialReference; using (IFeatureCursor cursor = sourceFc.GetFeatures(filter)) { if (cursor.NextFeature == null) { column++; report.featurePos++; if (ReportProgress != null && report.featurePos % reportInterval == 0) { ReportProgress(report); } continue; } } } string relFilename = level + "/" + row + "/" + column + ".bin"; if (_createTiles) { string filename = di.FullName + @"\" + column; if (_gridType == TileGridType.binary_float) { float[] vals = gridClass.MultiGridQuery( null, new IPoint[] { ring[0], ring[1], ring[3] }, _resX, _resY, fc.SpatialReference, null); if (!HasFloatArrayData(vals)) { column++; report.featurePos++; if (ReportProgress != null && report.featurePos % reportInterval == 0) { ReportProgress(report); } continue; } StoreFloatArray(filename + ".bin", x, y, _resX, _resY, vals); } else if (map != null) { map.ZoomTo(new Envelope(x, y, x + _tileSizeX, y + _tileSizeY)); map.RefreshMap(DrawPhase.All, _cancelTracker); if (_gridType == TileGridType.image_png) { map.Bitmap.Save(filename + ".png", System.Drawing.Imaging.ImageFormat.Png); } else if (_gridType == TileGridType.image_jpg) { map.Bitmap.Save(filename + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg); } } } Feature feature = new Feature(); feature.Shape = polygon; feature.Fields.Add(new FieldValue("GRID_LEVEL", level)); feature.Fields.Add(new FieldValue("GRID_ROW", row)); feature.Fields.Add(new FieldValue("GRID_COLUMN", column)); feature.Fields.Add(new FieldValue("FILE", relFilename)); features.Add(feature); column++; report.featurePos++; if (features.Count >= reportInterval) { if (ReportProgress != null) { ReportProgress(report); } if (!_fdb.Insert(fc, features)) { MessageBox.Show(_fdb.lastErrorMsg, "DB Insert Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } features.Clear(); if (!_cancelTracker.Continue) { succeeded = true; return; } } } row++; } } if (_levelType == TileLevelType.ConstantImagesize) { _tileSizeX *= 2; _tileSizeY *= 2; } _resX *= 2; _resY *= 2; } if (features.Count > 0) { if (ReportProgress != null) { ReportProgress(report); } _fdb.Insert(fc, features); } _fdb.CalculateExtent(fc); #endregion succeeded = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "Exception", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { if (!succeeded) { _fdb.DeleteFeatureClass(_name); } } }
async private Task InvokeSetExplorerObject() { _exObjectInvokeRequired = false; mapView1.CancelDrawing(DrawPhase.All); foreach (IDatasetElement element in _map.MapElements) { _map.RemoveLayer(element as ILayer); } if (_exObject != null) { var instance = await _exObject.GetInstanceAsync(); if (instance is IFeatureClass && ((IFeatureClass)instance).Envelope != null) { mapView1.Map = _map; _map.AddLayer(LayerFactory.Create(instance as IClass)); _map.Display.Limit = ((IFeatureClass)instance).Envelope; _map.Display.ZoomTo(((IFeatureClass)instance).Envelope); } else if (instance is IRasterClass && ((IRasterClass)instance).Polygon != null) { mapView1.Map = _map; _map.AddLayer(LayerFactory.Create(instance as IClass)); _map.Display.Limit = ((IRasterClass)instance).Polygon.Envelope; _map.Display.ZoomTo(((IRasterClass)instance).Polygon.Envelope); } else if (instance is IWebServiceClass && ((IWebServiceClass)instance).Envelope != null) { mapView1.Map = _map; _map.AddLayer(LayerFactory.Create(instance as IClass)); _map.Display.Limit = ((IWebServiceClass)instance).Envelope; _map.Display.ZoomTo(((IWebServiceClass)instance).Envelope); } else if (instance is IFeatureDataset) { mapView1.Map = _map; IFeatureDataset dataset = (IFeatureDataset)instance; foreach (IDatasetElement element in await dataset.Elements()) { ILayer layer = LayerFactory.Create(element.Class) as ILayer; if (layer == null) { continue; } _map.AddLayer(layer); } _map.Display.Limit = await dataset.Envelope(); _map.Display.ZoomTo(await dataset.Envelope()); } else if (instance is Map) { Map map = (Map)instance; map.NewBitmap -= InvokeNewBitmapCreated; map.DoRefreshMapView -= InvokeDoRefreshMapView; map.NewBitmap += InvokeNewBitmapCreated; map.DoRefreshMapView += InvokeDoRefreshMapView; mapView1.Map = (Map)instance; } } }
private void InkokeSetExplorerObject() { if (this.InvokeRequired) { this.Invoke(new MethodInvoker(() => { InkokeSetExplorerObject(); })); } else { mapView1.CancelDrawing(DrawPhase.All); foreach (IDatasetElement element in _map.MapElements) { _map.RemoveLayer(element as ILayer); } if (_exObject != null) { if (_exObject.Object is IFeatureClass && ((IFeatureClass)_exObject.Object).Envelope != null) { mapView1.Map = _map; _map.AddLayer(LayerFactory.Create(_exObject.Object as IClass)); _map.Display.Limit = ((IFeatureClass)_exObject.Object).Envelope; _map.Display.ZoomTo(((IFeatureClass)_exObject.Object).Envelope); } else if (_exObject.Object is IRasterClass && ((IRasterClass)_exObject.Object).Polygon != null) { mapView1.Map = _map; _map.AddLayer(LayerFactory.Create(_exObject.Object as IClass)); _map.Display.Limit = ((IRasterClass)_exObject.Object).Polygon.Envelope; _map.Display.ZoomTo(((IRasterClass)_exObject.Object).Polygon.Envelope); } else if (_exObject.Object is IWebServiceClass && ((IWebServiceClass)_exObject.Object).Envelope != null) { mapView1.Map = _map; _map.AddLayer(LayerFactory.Create(_exObject.Object as IClass)); _map.Display.Limit = ((IWebServiceClass)_exObject.Object).Envelope; _map.Display.ZoomTo(((IWebServiceClass)_exObject.Object).Envelope); } else if (_exObject.Object is IFeatureDataset) { mapView1.Map = _map; IFeatureDataset dataset = (IFeatureDataset)_exObject.Object; foreach (IDatasetElement element in dataset.Elements) { ILayer layer = LayerFactory.Create(element.Class) as ILayer; if (layer == null) { continue; } _map.AddLayer(layer); } _map.Display.Limit = dataset.Envelope; _map.Display.ZoomTo(dataset.Envelope); } else if (_exObject.Object is Map) { Map map = (Map)_exObject.Object; map.NewBitmap -= new NewBitmapEvent(mapView1.NewBitmapCreated); map.DoRefreshMapView -= new DoRefreshMapViewEvent(mapView1.MakeMapViewRefresh); map.NewBitmap += new NewBitmapEvent(mapView1.NewBitmapCreated); map.DoRefreshMapView += new DoRefreshMapViewEvent(mapView1.MakeMapViewRefresh); mapView1.Map = (Map)_exObject.Object; } } } }
public void OnEvent(object element, object dataset) { if (!(element is IDatasetElement) || !(dataset is IDataset)) { return; } TOC toc = _doc.FocusMap.TOC as TOC; if (toc == null) { return; } ITOCElement tocElement = toc.GetTOCElement(((IDatasetElement)element).Class); if (tocElement == null) { return; } ITOCElement parentTocElement = tocElement.ParentGroup; //IDatasetElement e = ((IDataset)dataset)[((IDatasetElement)element).Title]; //if (e == null) return; if (!(element is ILayer)) { return; } FormSplitLayerWithFilter dlg = new FormSplitLayerWithFilter(_doc, element as ILayer); if (dlg.ShowDialog() == DialogResult.OK) { foreach (FormSplitLayerWithFilter.FilterExpessionItem expression in dlg.FilterExpressions) { ILayer newLayer = LayerFactory.Create(((IDatasetElement)element).Class); if (newLayer is IFeatureLayer && element is IFeatureLayer && ((IFeatureLayer)element).Joins != null) { ((IFeatureLayer)newLayer).Joins = ((IFeatureLayer)element).Joins.Clone() as FeatureLayerJoins; } if (newLayer is IFeatureLayer) { QueryFilter filter = new QueryFilter(); filter.WhereClause = expression.Filter; ((IFeatureLayer)newLayer).FilterQuery = filter; _doc.FocusMap.AddLayer(newLayer); tocElement = toc.GetTOCElement(newLayer); tocElement.Name = expression.Text; toc.Add2Group(tocElement, parentTocElement); } } if (_doc.Application is IMapApplication) { ((IMapApplication)_doc.Application).RefreshActiveMap(Framework.Carto.DrawPhase.All); } } }
public bool Open() { try { _opened = true; _themes.Clear(); MapServerConnection server = new MapServerConnection(ConfigTextStream.ExtractValue(_connection, "server")); string axl = "<ARCXML version=\"1.1\"><REQUEST><GET_SERVICE_INFO fields=\"true\" envelope=\"true\" renderer=\"false\" extensions=\"false\" gv_meta=\"true\" /></REQUEST></ARCXML>"; axl = server.Send(_name, axl, "BB294D9C-A184-4129-9555-398AA70284BC", ConfigTextStream.ExtractValue(_connection, "user"), ConfigTextStream.ExtractValue(_connection, "pwd")); XmlDocument doc = new XmlDocument(); doc.LoadXml(axl); if (_class == null) { _class = new MapServerClass(this); } double dpi = 96.0; XmlNode screen = doc.SelectSingleNode("//ENVIRONMENT/SCREEN"); if (screen != null) { if (screen.Attributes["dpi"] != null) { dpi = Convert.ToDouble(screen.Attributes["dpi"].Value.Replace(".", ",")); } } double dpm = (dpi / 0.0254); XmlNode spatialReference = doc.SelectSingleNode("//PROPERTIES/SPATIALREFERENCE"); if (spatialReference != null) { if (spatialReference.Attributes["param"] != null) { SpatialReference sRef = new SpatialReference(); gView.Framework.Geometry.SpatialReference.FromProj4(sRef, spatialReference.Attributes["param"].Value); if (spatialReference.Attributes["name"] != null) { sRef.Name = spatialReference.Attributes["name"].Value; } _class.SpatialReference = sRef; } } else { XmlNode FeatureCoordSysNode = doc.SelectSingleNode("ARCXML/RESPONSE/SERVICEINFO/PROPERTIES/FEATURECOORDSYS"); if (FeatureCoordSysNode != null) { if (FeatureCoordSysNode.Attributes["id"] != null) { _class.SpatialReference = gView.Framework.Geometry.SpatialReference.FromID("epsg:" + FeatureCoordSysNode.Attributes["id"].Value); } else if (FeatureCoordSysNode.Attributes["string"] != null) { _class.SpatialReference = gView.Framework.Geometry.SpatialReference.FromWKT(FeatureCoordSysNode.Attributes["string"].Value); } // TODO: Geogr. Datum aus "datumtransformid" und "datumtransformstring" //if (_sRef != null && FeatureCoordSysNode.Attributes["datumtransformstring"] != null) //{ //} } } foreach (XmlNode envelopeNode in doc.SelectNodes("//ENVELOPE")) { if (_envelope == null) { _envelope = (new Envelope(envelopeNode)).MakeValid(); } else { _envelope.Union((new Envelope(envelopeNode)).MakeValid()); } } foreach (XmlNode layerNode in doc.SelectNodes("//LAYERINFO[@id]")) { bool visible = true; ISpatialReference sRef = _class.SpatialReference; /* * spatialReference = doc.SelectSingleNode("//PROPERTIES/SPATIALREFERENCE"); * if (spatialReference != null) * { * if (spatialReference.Attributes["param"] != null) * { * sRef = new SpatialReference(); * gView.Framework.Geometry.SpatialReference.FromProj4(sRef, spatialReference.Attributes["param"].Value); * * if (spatialReference.Attributes["name"] != null) * ((SpatialReference)sRef).Name = spatialReference.Attributes["name"].Value; * } * } * else * { * XmlNode FeatureCoordSysNode = doc.SelectSingleNode("ARCXML/RESPONSE/SERVICEINFO/PROPERTIES/FEATURECOORDSYS"); * if (FeatureCoordSysNode != null) * { * if (FeatureCoordSysNode.Attributes["id"] != null) * { * sRef = gView.Framework.Geometry.SpatialReference.FromID("epsg:" + FeatureCoordSysNode.Attributes["id"].Value); * } * else if (FeatureCoordSysNode.Attributes["string"] != null) * { * sRef = gView.Framework.Geometry.SpatialReference.FromWKT(FeatureCoordSysNode.Attributes["string"].Value); * } * * // TODO: Geogr. Datum aus "datumtransformid" und "datumtransformstring" * //if (_sRef != null && FeatureCoordSysNode.Attributes["datumtransformstring"] != null) * //{ * * //} * } * } */ if (layerNode.Attributes["visible"] != null) { bool.TryParse(layerNode.Attributes["visible"].Value, out visible); } IClass themeClass = null; IWebServiceTheme theme = null; if (layerNode.Attributes["type"] != null && layerNode.Attributes["type"].Value == "featureclass") { themeClass = new MapThemeFeatureClass(this, layerNode.Attributes["id"].Value); ((MapThemeFeatureClass)themeClass).Name = layerNode.Attributes["name"] != null ? layerNode.Attributes["name"].Value : layerNode.Attributes["id"].Value; ((MapThemeFeatureClass)themeClass).fieldsFromAXL = layerNode.InnerXml; ((MapThemeFeatureClass)themeClass).SpatialReference = sRef; XmlNode FCLASS = layerNode.SelectSingleNode("FCLASS[@type]"); if (FCLASS != null) { ((MapThemeFeatureClass)themeClass).fClassTypeString = FCLASS.Attributes["type"].Value; } theme = LayerFactory.Create(themeClass, _class) as IWebServiceTheme; if (theme == null) { continue; } theme.Visible = visible; } else if (layerNode.Attributes["type"] != null && layerNode.Attributes["type"].Value == "image") { if (layerNode.SelectSingleNode("gv_meta/class/implements[@type='gView.Framework.Data.IPointIdentify']") != null) { themeClass = new MapThemeQueryableRasterClass(this, layerNode.Attributes["id"].Value); ((MapThemeQueryableRasterClass)themeClass).Name = layerNode.Attributes["name"] != null ? layerNode.Attributes["name"].Value : layerNode.Attributes["id"].Value; } else { themeClass = new MapThemeRasterClass(this, layerNode.Attributes["id"].Value); ((MapThemeRasterClass)themeClass).Name = layerNode.Attributes["name"] != null ? layerNode.Attributes["name"].Value : layerNode.Attributes["id"].Value; } theme = new WebServiceTheme( themeClass, themeClass.Name, layerNode.Attributes["id"].Value, visible, _class); } else { continue; } try { if (layerNode.Attributes["minscale"] != null) { theme.MinimumScale = Convert.ToDouble(layerNode.Attributes["minscale"].Value.Replace(".", ",")) * dpm; } if (layerNode.Attributes["maxscale"] != null) { theme.MaximumScale = Convert.ToDouble(layerNode.Attributes["maxscale"].Value.Replace(".", ",")) * dpm; } } catch { } _themes.Add(theme); } _state = DatasetState.opened; return(true); } catch (Exception ex) { _state = DatasetState.unknown; _class = null; return(false); } }
public Task <bool> OnEvent(object element, object dataset) { if (!(element is IDatasetElement) || !(dataset is IDataset)) { return(Task.FromResult(true)); } TOC toc = _doc.FocusMap.TOC as TOC; if (toc == null) { return(Task.FromResult(true)); } ITOCElement tocElement = toc.GetTOCElement(((IDatasetElement)element).Class); if (tocElement == null) { return(Task.FromResult(true)); } ILayer newLayer = LayerFactory.Create(((IDatasetElement)element).Class); if (newLayer is IFeatureLayer && element is IFeatureLayer) { if (((IFeatureLayer)element).Joins != null) { ((IFeatureLayer)newLayer).Joins = ((IFeatureLayer)element).Joins.Clone() as FeatureLayerJoins; } if (((IFeatureLayer)element).FilterQuery != null) { QueryFilter filter = new QueryFilter(); filter.WhereClause = ((IFeatureLayer)element).FilterQuery.WhereClause; ((IFeatureLayer)newLayer).FilterQuery = filter; } ((IFeatureLayer)newLayer).FeatureRenderer = ((IFeatureLayer)element).FeatureRenderer.Clone() as IFeatureRenderer ?? ((IFeatureLayer)newLayer).FeatureRenderer; ((IFeatureLayer)newLayer).LabelRenderer = ((IFeatureLayer)element).LabelRenderer?.Clone() as ILabelRenderer ?? ((IFeatureLayer)newLayer).LabelRenderer; ((IFeatureLayer)newLayer).MinimumScale = ((IFeatureLayer)element).MinimumScale; ((IFeatureLayer)newLayer).MaximumScale = ((IFeatureLayer)element).MaximumScale; ((IFeatureLayer)newLayer).MinimumLabelScale = ((IFeatureLayer)element).MinimumLabelScale; ((IFeatureLayer)newLayer).MaximumLabelScale = ((IFeatureLayer)element).MaximumLabelScale; ((IFeatureLayer)newLayer).MaxRefScaleFactor = ((IFeatureLayer)element).MaxRefScaleFactor; ((IFeatureLayer)newLayer).MaxLabelRefScaleFactor = ((IFeatureLayer)element).MaxLabelRefScaleFactor; } if (newLayer == null) { return(Task.FromResult(true)); } _doc.FocusMap.AddLayer(newLayer); if (_doc.Application is IMapApplication) { ((IMapApplication)_doc.Application).RefreshActiveMap(Framework.Carto.DrawPhase.All); } return(Task.FromResult(true)); }
public bool Open() { try { _state = DatasetState.unknown; _elements.Clear(); FileInfo fi_gml = new FileInfo(_connectionString); if (!fi_gml.Exists) { return(false); } FileInfo fi_xsd = new FileInfo(fi_gml.FullName.Substring(0, fi_gml.FullName.Length - fi_gml.Extension.Length) + ".xsd"); if (!fi_xsd.Exists) { return(false); } _gml_file = fi_gml.FullName; _xsd_file = fi_xsd.FullName; XmlDocument schema = new XmlDocument(); schema.Load(System.IO.File.ReadAllText(fi_xsd.FullName)); XmlSchemaReader schemaReader = new XmlSchemaReader(schema); string targetNamespace = schemaReader.TargetNamespaceURI; if (targetNamespace == String.Empty) { return(false); } PlugInManager compMan = new PlugInManager(); foreach (string elementName in schemaReader.ElementNames) { string shapeFieldName; geometryType geomType; Fields fields = schemaReader.ElementFields(elementName, out shapeFieldName, out geomType); FeatureClass fc = new FeatureClass(this, elementName, fields); fc.ShapeFieldName = shapeFieldName; fc.GeometryType = geomType; IFeatureLayer layer = LayerFactory.Create(fc) as IFeatureLayer; if (layer == null) { continue; } //layer.FeatureRenderer = compMan.getComponent(KnownObjects.Carto_UniversalGeometryRenderer) as IFeatureRenderer; _elements.Add(layer); } _doc = new XmlDocument(); using (XmlTextReader xmlTextReader = new XmlTextReader(fi_gml.FullName)) { xmlTextReader.ReadToDescendant("boundedBy", "http://www.opengis.net/gml"); string boundedBy = xmlTextReader.ReadOuterXml(); _doc.LoadXml(boundedBy); } _ns = new XmlNamespaceManager(_doc.NameTable); _ns.AddNamespace("GML", "http://www.opengis.net/gml"); _ns.AddNamespace("WFS", "http://www.opengis.net/wfs"); _ns.AddNamespace("OGC", "http://www.opengis.net/ogc"); _ns.AddNamespace("myns", targetNamespace); XmlNode boundedByNode = _doc.ChildNodes[0]; if (boundedByNode != null) { XmlNode geomNode = boundedByNode.SelectSingleNode("GML:*", _ns); if (geomNode != null) { _envelope = GeometryTranslator.GML2Geometry(geomNode.OuterXml, _gmlVersion) as IEnvelope; if (geomNode.Attributes["srsName"] != null) { _sRef = gView.Framework.Geometry.SpatialReference.FromID(geomNode.Attributes["srsName"].Value); } } } _state = DatasetState.opened; return(true); } catch (Exception ex) { _errMsg = ex.Message; return(false); } }
private void ServiceMap_BeforeRenderLayers(Framework.Carto.IServiceMap sender, List <Framework.Data.ILayer> layers) { if (String.IsNullOrWhiteSpace(_exportMap?.Layers) || !_exportMap.Layers.Contains(":")) { return; } string option = _exportMap.Layers.Substring(0, _exportMap.Layers.IndexOf(":")).ToLower(); int[] layerIds = _exportMap.Layers.Substring(_exportMap.Layers.IndexOf(":") + 1) .Split(',').Select(l => int.Parse(l)).ToArray(); foreach (var layer in layers) { switch (option) { case "show": layer.Visible = layerIds.Contains(layer.ID); break; case "hide": layer.Visible = !layerIds.Contains(layer.ID); break; case "include": if (layerIds.Contains(layer.ID)) { layer.Visible = true; } break; case "exclude": if (layerIds.Contains(layer.ID)) { layer.Visible = false; } break; } } if (!String.IsNullOrWhiteSpace(_exportMap.DynamicLayers)) { var jsonDynamicLayers = JsonConvert.DeserializeObject <JsonDynamicLayer[]>(_exportMap.DynamicLayers); foreach (var jsonDynamicLayer in jsonDynamicLayers) { if (jsonDynamicLayer.Source != null) { var featureLayers = MapServerHelper.FindMapLayers(sender, _useTOC, jsonDynamicLayer.Source.MapLayerId.ToString()); foreach (var featureLayer in featureLayers) { if (!(featureLayer.Class is IFeatureClass)) { continue; } IFeatureClass fc = (IFeatureClass)featureLayer.Class; var dynLayer = LayerFactory.Create(featureLayer.Class, featureLayer) as IFeatureLayer; if (dynLayer != null) { if (jsonDynamicLayer.DrawingInfo.Renderer != null) { if (jsonDynamicLayer.DrawingInfo.Renderer.Type.ToLower() == "simple") { var renderer = new SimpleRenderer(); if (fc.GeometryType == geometryType.Point) { var jsonRenderer = JsonConvert.DeserializeObject <SimpleMarkerSymbol>(jsonDynamicLayer.DrawingInfo.Renderer.Symbol.ToString()); if (jsonRenderer.Style == "esriSMSCircle") { var symbol = new gView.Framework.Symbology.SimplePointSymbol(); symbol.SymbolSmothingMode = Framework.Symbology.SymbolSmoothing.AntiAlias; symbol.FillColor = ToColor(jsonRenderer.Color); symbol.Size = jsonRenderer.Size; if (jsonRenderer.Outline != null) { symbol.OutlineColor = ToColor(jsonRenderer.Outline.Color); symbol.OutlineWidth = jsonRenderer.Outline.Width; } renderer.Symbol = symbol; } else { throw new Exception("Unsupported MarkerSymbolStyle: " + jsonRenderer.Style); } } else if (fc.GeometryType == geometryType.Polyline) { var jsonRenderer = JsonConvert.DeserializeObject <SimpleLineSymbol>(jsonDynamicLayer.DrawingInfo.Renderer.Symbol.ToString()); var symbol = new gView.Framework.Symbology.SimpleLineSymbol(); symbol.SymbolSmothingMode = Framework.Symbology.SymbolSmoothing.AntiAlias; symbol.Color = ToColor(jsonRenderer.Color); symbol.Width = jsonRenderer.Width; renderer.Symbol = symbol; } else if (fc.GeometryType == geometryType.Polygon) { var jsonRenderer = JsonConvert.DeserializeObject <SimpleFillSymbol>(jsonDynamicLayer.DrawingInfo.Renderer.Symbol.ToString()); var symbol = new gView.Framework.Symbology.SimpleFillSymbol(); symbol.SymbolSmothingMode = Framework.Symbology.SymbolSmoothing.AntiAlias; symbol.FillColor = ToColor(jsonRenderer.Color); if (jsonRenderer.Outline != null) { symbol.OutlineColor = ToColor(jsonRenderer.Outline.Color); symbol.OutlineWidth = jsonRenderer.Outline.Width; } renderer.Symbol = symbol; } else { throw new ArgumentException("Unsupported dynamic layer geometry: " + fc.GeometryType.ToString()); } dynLayer.FeatureRenderer = renderer; } else { throw new ArgumentException("Unknwon renderer type: " + jsonDynamicLayer.DrawingInfo.Renderer.Type); } } dynLayer.FilterQuery = new QueryFilter() { SubFields = "*", WhereClause = jsonDynamicLayer.DefinitionExpression }; dynLayer.Visible = true; layers.Add(dynLayer); } } } } } }
private void btnStart_Click(object sender, EventArgs e) { txtMap.Text = txtMap.Text.ToUpper().Replace(" ", "_").Replace("Ä", "AE").Replace("Ö", "OE").Replace("Ü", "UE").Replace("ß", "SS"); _filter = ((ExportMethodItem)cmbExport.SelectedItem).QueryFilter; Map migMap = new Map(); migMap.Name = txtMap.Text; migMap.Display.refScale = _map.Display.refScale; migMap.Display.MapUnits = _map.Display.MapUnits; migMap.Display.DisplayUnits = _map.Display.DisplayUnits; migMap.Display.SpatialReference = _map.Display.SpatialReference; _doc.AddMap(migMap); _doc.FocusMap = migMap; migMap.Display.ZoomTo(_map.Display.Envelope); List <string> migratedClassNames = new List <string>(); foreach (IDatasetElement element in _map.MapElements) { if (!(element is IFeatureLayer) || element.Class == null) { continue; } try { if (element.Class is IFeatureClass) { IFeatureClass fc = (IFeatureClass)element.Class; if (!migratedClassNames.Contains(fc.Name)) { ExportDatasetObject(fc); migratedClassNames.Add(fc.Name); } } } catch (Exception ex) { if (MessageBox.Show(ex.Message + "\n\nDo you want to continue?", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error) != DialogResult.OK) { break; } } IDatasetElement destDatasetElement = _dataset[(txtMap.Text + "_" + element.Class.Name).Replace(".", "_")]; if (destDatasetElement != null) { IFeatureLayer sourceLayer = (IFeatureLayer)element; IFeatureLayer layer = LayerFactory.Create(destDatasetElement.Class) as IFeatureLayer; if (layer != null) { if (sourceLayer.FeatureRenderer != null) { layer.FeatureRenderer = sourceLayer.FeatureRenderer.Clone(migMap.Display) as IFeatureRenderer; } if (sourceLayer.LabelRenderer != null) { layer.LabelRenderer = sourceLayer.LabelRenderer.Clone(migMap.Display) as ILabelRenderer; } if (sourceLayer.SelectionRenderer != null) { layer.SelectionRenderer = sourceLayer.SelectionRenderer.Clone(migMap.Display) as IFeatureRenderer; } layer.MinimumLabelScale = sourceLayer.MinimumLabelScale; layer.MaximumLabelScale = sourceLayer.MaximumLabelScale; layer.MinimumScale = sourceLayer.MinimumScale; layer.MaximumScale = sourceLayer.MaximumScale; layer.Visible = sourceLayer.Visible; } layer.SID = sourceLayer.SID; migMap.AddLayer(layer); ITOCElement tocElement = migMap.TOC.GetTOCElement(layer); ITOCElement sourceTocElement = _map.TOC.GetTOCElement(sourceLayer); if (tocElement != null && sourceTocElement != null) { tocElement.Name = sourceTocElement.Name; } } } if (_doc.Application is IMapApplication) { ((IMapApplication)_doc.Application).RefreshActiveMap(DrawPhase.All); } }
public bool Open(gView.MapServer.IServiceRequestContext context) { if (_class == null) { _class = new AGSClass(this); } #region Parameters string server = ConfigTextStream.ExtractValue(ConnectionString, "server"); string service = ConfigTextStream.ExtractValue(ConnectionString, "service"); string user = ConfigTextStream.ExtractValue(ConnectionString, "user"); string pwd = ConfigTextStream.ExtractValue(ConnectionString, "pwd"); if ((user == "#" || user == "$") && context != null && context.ServiceRequest != null && context.ServiceRequest.Identity != null) { string roles = String.Empty; if (user == "#" && context.ServiceRequest.Identity.UserRoles != null) { foreach (string role in context.ServiceRequest.Identity.UserRoles) { if (String.IsNullOrEmpty(role)) { continue; } roles += "|" + role; } } user = context.ServiceRequest.Identity.UserName + roles; pwd = context.ServiceRequest.Identity.HashedPassword; } #endregion try { _proxy = ProxySettings.Proxy(server); _themes.Clear(); _parentIds.Clear(); _mapServer = new gView.Interoperability.AGS.Proxy.MapServer(service); _mapServer.Proxy = gView.Framework.Web.ProxySettings.Proxy(service); MapServerInfo msi = _mapServer.GetServerInfo(_mapServer.GetDefaultMapName()); _mapDescription = msi.DefaultMapDescription; MapLayerInfo[] mapLayerInfos = msi.MapLayerInfos; foreach (MapLayerInfo layerInfo in mapLayerInfos) { if (layerInfo.Extent is EnvelopeN) { EnvelopeN env = (EnvelopeN)layerInfo.Extent; if (_envelope == null) { _envelope = new gView.Framework.Geometry.Envelope(env.XMin, env.YMin, env.XMax, env.YMax); } else { _envelope.Union(new gView.Framework.Geometry.Envelope(env.XMin, env.YMin, env.XMax, env.YMax)); } } CalcParentLayerIds(mapLayerInfos, layerInfo.LayerID); IClass themeClass = null; IWebServiceTheme theme = null; LayerDescription ld = LayerDescriptionById(layerInfo.LayerID); if (ld == null) { continue; } if (layerInfo.LayerType == "Feature Layer") { #region Geometry Type (Point, Line, Polygon) geometryType geomType = geometryType.Unknown; if (layerInfo.Fields != null) { foreach (Proxy.Field fieldInfo in layerInfo.Fields.FieldArray) { if (fieldInfo.Type == esriFieldType.esriFieldTypeGeometry && fieldInfo.GeometryDef != null) { switch (fieldInfo.GeometryDef.GeometryType) { case esriGeometryType.esriGeometryMultipoint: case esriGeometryType.esriGeometryPoint: geomType = geometryType.Point; break; case esriGeometryType.esriGeometryPolyline: geomType = geometryType.Polyline; break; case esriGeometryType.esriGeometryPolygon: geomType = geometryType.Polygon; break; case esriGeometryType.esriGeometryMultiPatch: break; } } } } #endregion themeClass = new AGSThemeFeatureClass(this, layerInfo, geomType); theme = LayerFactory.Create(themeClass, _class as IWebServiceClass) as IWebServiceTheme; if (theme == null) { continue; } } else if (layerInfo.LayerType == "Raster Layer" || layerInfo.LayerType == "Raster Catalog Layer") { themeClass = new AGSThemeRasterClass(this, layerInfo); theme = LayerFactory.Create(themeClass, _class as IWebServiceClass) as IWebServiceTheme; if (theme == null) { continue; } } else { MapLayerInfo parentLayer = MapLayerInfoById(mapLayerInfos, layerInfo.ParentLayerID); if (parentLayer != null && parentLayer.LayerType == "Annotation Layer") { themeClass = new AGSThemeFeatureClass(this, layerInfo, geometryType.Polygon); theme = LayerFactory.Create(themeClass, _class as IWebServiceClass) as IWebServiceTheme; if (theme == null) { continue; } } } if (theme != null) { theme.MinimumScale = layerInfo.MaxScale; theme.MaximumScale = layerInfo.MinScale; theme.Visible = ld.Visible; _themes.Add(theme); } } _state = DatasetState.opened; return(true); } catch (Exception ex) { _state = DatasetState.unknown; _errMsg = ex.Message; return(false); } }
async public Task <IBitmap> Legend() { ITOC toc = _toc.Clone(this) as ITOC; #region WebServiceLayer List <IWebServiceLayer> webServices; if (this.TOC != null) { webServices = ListOperations <IWebServiceLayer> .Swap(this.TOC.VisibleWebServiceLayers); } else { webServices = new List <IWebServiceLayer>(); foreach (IDatasetElement layer in this.MapElements) { if (!(layer is IWebServiceLayer)) { continue; } if (((ILayer)layer).Visible) { webServices.Add((IWebServiceLayer)layer); } } } foreach (IWebServiceLayer element in webServices) { if (!(element is ILayer)) { continue; } if (!element.Visible) { continue; } IWebServiceLayer wsLayer = LayerFactory.Create(element.WebServiceClass.Clone() as IClass, element) as IWebServiceLayer; if (wsLayer == null || wsLayer.WebServiceClass == null) { continue; } if (BeforeRenderLayers != null) { // layer im geklonten TOC austauschen... // Besser layer als layer.Class verwendenden, weil Class von mehrerenen Layern // verwendet werden kann zB bei gesplitteten Layern... //ITOCElement tocElement = toc.GetTOCElement(element.Class); ITOCElement tocElement = toc.GetTOCElement(element); tocElement.RemoveLayer(element); tocElement.AddLayer(wsLayer); List <ILayer> modLayers = new List <ILayer>(); foreach (IWebServiceTheme theme in wsLayer.WebServiceClass.Themes) { if (theme is ILayer) { modLayers.Add(theme); } } BeforeRenderLayers(this, modLayers); } } #endregion List <ILayer> layers = new List <ILayer>(); if (this.TOC != null) { if (this.GetType().Equals(typeof(ServiceMap))) { layers = ListOperations <ILayer> .Swap(this.TOC.Layers); } else { layers = ListOperations <ILayer> .Swap(this.TOC.VisibleLayers); } } else { layers = new List <ILayer>(); foreach (IDatasetElement layer in this.MapElements) { if (!(layer is ILayer)) { continue; } if (((ILayer)layer).Visible) { layers.Add((ILayer)layer); } } } if (BeforeRenderLayers != null) { // // Kopie der Original Layer erstellen // ACHTUNG: Renderer werden nicht kopiert! // dürfen in BeforeRenderLayers nicht verändert werden... // Eine zuweisung eines neuen Renderers ist jedoch legitim. // List <ILayer> modLayers = new List <ILayer>(); foreach (IDatasetElement element in layers) { if (!(element is ILayer) || element is IWebServiceTheme) { continue; } ILayer layer = (ILayer)element; if (layer.MinimumScale > 1 && layer.MinimumScale > this.mapScale) { continue; } if (layer.MaximumScale > 1 && layer.MaximumScale < this.mapScale) { continue; } ILayer newLayer = null; modLayers.Add(newLayer = LayerFactory.Create(layer.Class, layer)); // layer im geklonten TOC austauschen... if (element is ILayer && newLayer != null) { // Besser layer als layer.Class verwendenden, weil Class von mehrerenen Layern // verwendet werden kann zB bei gesplitteten Layern... //ITOCElement tocElement = toc.GetTOCElement(layer.Class); ITOCElement tocElement = toc.GetTOCElement(layer); tocElement.RemoveLayer(element as ILayer); tocElement.AddLayer(newLayer); } } BeforeRenderLayers(this, modLayers); layers = modLayers; } return(await toc.Legend()); }
public void LoadMapDocument(string filename) { if (_doc == null || filename == "") { return; } _docFilename = filename; System.IO.FileInfo fi = new System.IO.FileInfo(filename); if (!fi.Exists) { return; } if (fi.Extension.ToLower() != ".axl") { RemoveAllDataViews(); if (_appWindow != null) { _appWindow.RemoveAllToolbars(); } _activeDataView = null; } XmlStream stream = new XmlStream(""); if (fi.Extension.ToLower() == ".rdm") { StreamReader sr = new StreamReader(filename); byte[] bytes = new byte[fi.Length]; BinaryReader br = new BinaryReader(sr.BaseStream); br.Read(bytes, 0, bytes.Length); sr.Close(); bytes = Crypto.Decrypt(bytes, _cryptoKey); MemoryStream ms = new MemoryStream(bytes); stream.ReadStream(ms); ms.Close(); } else if (fi.Extension.ToLower() == ".axl") { IMap map = _doc.Maps[0]; PlugInManager pman = new PlugInManager(); #region AXL XmlDocument axl = new XmlDocument(); axl.Load(fi.FullName); #region Extent XmlNode envNode = axl.SelectSingleNode("ARCXML/CONFIG/MAP/PROPERTIES/ENVELOPE[@minx and @maxx and @miny and @miny]"); if (envNode != null) { Envelope env = new Envelope(envNode); map.Display.Limit = new Envelope(env); map.Display.ZoomTo(env); } #endregion #region Workspaces Dictionary <string, IDataset> _workspaces = new Dictionary <string, IDataset>(); foreach (XmlNode workspaceNode in axl.SelectNodes("ARCXML/CONFIG/MAP/WORKSPACES/*")) { switch (workspaceNode.Name) { case "SDEWORKSPACE": string connectionString = "server=" + workspaceNode.Attributes["server"].Value; if (workspaceNode.Attributes["instance"] != null) { connectionString += ";instance=" + workspaceNode.Attributes["instance"].Value; } if (workspaceNode.Attributes["database"] != null) { connectionString += ";database=" + workspaceNode.Attributes["database"].Value; } if (workspaceNode.Attributes["user"] != null) { connectionString += ";user="******"user"].Value; } if (workspaceNode.Attributes["password"] != null) { connectionString += ";password="******"password"].Value; } IDataset sdeDataset = pman.CreateInstance(new Guid("CE42218B-6962-48c9-9BAC-39E4C5003AE5")) as IDataset; if (sdeDataset == null) { continue; } sdeDataset.ConnectionString = connectionString; if (!sdeDataset.Open()) { continue; } _workspaces.Add(workspaceNode.Attributes["name"].Value, sdeDataset); break; case "SHAPEWORKSPACE": IDataset shapeDataset = pman.CreateInstance(new Guid("80F48262-D412-41fb-BF43-2D611A2ABF42")) as IDataset; if (shapeDataset == null) { continue; } shapeDataset.ConnectionString = workspaceNode.Attributes["directory"].Value; if (!shapeDataset.Open()) { continue; } _workspaces.Add(workspaceNode.Attributes["name"].Value, shapeDataset); break; case "IMAGEWORKSPACE": IDataset rasterDataset = pman.CreateInstance(new Guid("43DFABF1-3D19-438c-84DA-F8BA0B266592")) as IDataset; _workspaces.Add(workspaceNode.Attributes["name"].Value, rasterDataset); break; } } #endregion #region Layers XmlNodeList layerNodes = axl.SelectNodes("ARCXML/CONFIG/MAP/LAYER[@name and @id and @type]"); if (layerNodes == null) { return; } for (int i = layerNodes.Count - 1; i >= 0; i--) { XmlNode layerNode = layerNodes[i]; if (layerNode.Attributes["type"].Value == "featureclass") { XmlNode datasetNode = layerNode.SelectSingleNode("DATASET[@name and @workspace]"); if (datasetNode == null) { continue; } if (!_workspaces.ContainsKey(datasetNode.Attributes["workspace"].Value)) { continue; } IDataset dataset = _workspaces[datasetNode.Attributes["workspace"].Value]; IDatasetElement dsElement = dataset[datasetNode.Attributes["name"].Value]; if (dsElement == null || dsElement.Class == null) { continue; } IFeatureLayer layer = (IFeatureLayer)LayerFactory.Create(dsElement.Class); if (layerNode.Attributes["visible"] != null) { layer.Visible = layerNode.Attributes["visible"].Value == "true"; } layer.SID = layerNode.Attributes["id"].Value; map.AddLayer(layer); SetLayernameAndScales(layerNode, layer); SetRenderers(layerNode, layer); XmlNode queryNode = layerNode.SelectSingleNode("QUERY[@where]"); if (queryNode != null) { layer.FilterQuery = new QueryFilter(); layer.FilterQuery.WhereClause = queryNode.Attributes["where"].Value; } } else if (layerNode.Attributes["type"].Value == "image") { XmlNode datasetNode = layerNode.SelectSingleNode("DATASET[@name and @workspace]"); if (datasetNode == null) { continue; } if (!_workspaces.ContainsKey(datasetNode.Attributes["workspace"].Value)) { continue; } IRasterFileDataset dataset = _workspaces[datasetNode.Attributes["workspace"].Value] as IRasterFileDataset; if (dataset == null) { continue; } XmlNode workspaceNode = axl.SelectSingleNode("ARCXML/CONFIG/MAP/WORKSPACES/IMAGEWORKSPACE[@name='" + datasetNode.Attributes["workspace"].Value + "' and @directory]"); if (workspaceNode == null) { continue; } IRasterLayer rLayer = dataset.AddRasterFile(workspaceNode.Attributes["directory"].Value + @"\" + datasetNode.Attributes["name"].Value); if (rLayer == null) { continue; } if (layerNode.Attributes["visible"] != null) { rLayer.Visible = layerNode.Attributes["visible"].Value == "true"; } rLayer.SID = layerNode.Attributes["id"].Value; map.AddLayer(rLayer); SetLayernameAndScales(layerNode, rLayer); } } #endregion ValidateUI(); IsDirty = false; _appWindow.Title = "gView.Carto " + fi.Name; if (AfterLoadMapDocument != null) { AfterLoadMapDocument(_doc); } return; #endregion } else { stream.ReadStream(filename); } while (_doc.Maps.Count > 0) { _doc.RemoveMap(_doc.Maps[0]); } _dataViews.Clear(); stream.Load("MapDocument", null, _doc); // Load DataViews... DataView dv; while ((dv = (DataView)stream.Load("DataView", null, new DataView(_doc.Maps))) != null) { if (!(dv.Map is Map)) { continue; } DataView dataView = _appWindow.AddDataView((Map)dv.Map); if (dataView == null) { continue; } dataView.Envelope = dv.Envelope; dataView.TOC = dv.TOC; dataView.DisplayRotation = dv.DisplayRotation; if (_activeDataView == null) { _activeDataView = dataView; } } if (_dataViews.Count == 0 && _doc.Maps.Count > 0) { //_appWindow.AddDataView((Map)_doc.Maps[0]); _activeDataView = _dataViews[0]; } if (_activeDataView != null && _activeDataView.MapView != null) { _activeDataView.MapView.Tool = this.ActiveTool; } ValidateUI(); IsDirty = false; _appWindow.Title = "gView.Carto " + fi.Name; _readonly = (fi.Extension.ToLower() == ".rdm"); if (AfterLoadMapDocument != null) { AfterLoadMapDocument(_doc); } }
async override public Task <bool> RefreshMap(DrawPhase phase, ICancelTracker cancelTracker) { base.ResetRequestExceptions(); if (_canvas != null && phase == DrawPhase.Graphics) { return(true); } this.ZoomTo(m_actMinX, m_actMinY, m_actMaxX, m_actMaxY); if (cancelTracker == null) { cancelTracker = new CancelTracker(); } using (var datasetCachingContext = new DatasetCachingContext(this)) using (var geoTransformer = GeometricTransformerFactory.Create()) { //geoTransformer.ToSpatialReference = this.SpatialReference; if (_bitmap == null) { _bitmap = Current.Engine.CreateBitmap(iWidth, iHeight, PixelFormat.Rgba32); } _canvas = _bitmap.CreateCanvas(); //_canvas.CompositingMode = CompositingMode.SourceCopy; //this.dpi = _canvas.DpiX * this.ScaleSymbolFactor; if (BackgroundColor.A != 0 && !Display.MakeTransparent) { using (var brush = Current.Engine.CreateSolidBrush(BackgroundColor)) { _canvas.FillRectangle(brush, new CanvasRectangle(0, 0, _bitmap.Width, _bitmap.Height)); } } if (phase == DrawPhase.All || phase == DrawPhase.Geography) { this.GeometricTransformer = geoTransformer; // Thread für MapServer Datasets starten... #region WebServiceLayer List <IWebServiceLayer> webServices; if (this.TOC != null) { webServices = ListOperations <IWebServiceLayer> .Swap(this.TOC.VisibleWebServiceLayers); } else { webServices = new List <IWebServiceLayer>(); foreach (IDatasetElement layer in this.MapElements) { if (!(layer is IWebServiceLayer)) { continue; } if (((ILayer)layer).Visible) { webServices.Add((IWebServiceLayer)layer); } } } int webServiceOrder = 0, webServiceOrder2 = 1; foreach (IWebServiceLayer element in webServices) { if (!element.Visible) { continue; } IWebServiceLayer wsLayer = LayerFactory.Create(element.WebServiceClass.Clone() as IClass, element) as IWebServiceLayer; if (wsLayer == null || wsLayer.WebServiceClass == null) { continue; } wsLayer.WebServiceClass.SpatialReference = this.SpatialReference; List <IWebServiceClass> additionalWebServices = new List <IWebServiceClass>(); if (BeforeRenderLayers != null) { List <ILayer> modLayers = new List <ILayer>(); foreach (IWebServiceTheme theme in wsLayer.WebServiceClass.Themes) { if (theme is ILayer) { modLayers.Add(theme); } } BeforeRenderLayers(this, modLayers); foreach (ILayer additionalLayer in MapServerHelper.FindAdditionalWebServiceLayers(wsLayer.WebServiceClass, modLayers)) { IWebServiceClass additionalWebService = MapServerHelper.CloneNonVisibleWebServiceClass(wsLayer.WebServiceClass); MapServerHelper.CopyWebThemeProperties(additionalWebService, additionalLayer); if (MapServerHelper.HasVisibleThemes(additionalWebService)) { additionalWebServices.Add(additionalWebService); } } } var srt = new RenderServiceRequest(this, wsLayer, webServiceOrder++); srt.finish += new RenderServiceRequest.RequestThreadFinished(MapRequestThread_finished); //Thread thread = new Thread(new ThreadStart(srt.ImageRequest)); m_imageMerger.max++; //thread.Start(); var task = srt.ImageRequest(); // start Task and continue... foreach (IWebServiceClass additionalWebService in additionalWebServices) { wsLayer = LayerFactory.Create(additionalWebService, element) as IWebServiceLayer; if (wsLayer == null || wsLayer.WebServiceClass == null) { continue; } wsLayer.WebServiceClass.SpatialReference = this.SpatialReference; srt = new RenderServiceRequest(this, wsLayer, (++webServiceOrder2) + webServices.Count); srt.finish += new RenderServiceRequest.RequestThreadFinished(MapRequestThread_finished); //thread = new Thread(new ThreadStart(srt.ImageRequest)); m_imageMerger.max++; //thread.Start(); var additionalTask = srt.ImageRequest(); // start task and continue... } } #endregion List <ILayer> layers = new List <ILayer>(); if (this.TOC != null) { if (this.GetType().Equals(typeof(ServiceMap))) { layers = ListOperations <ILayer> .Swap(this.TOC.Layers); } else { layers = ListOperations <ILayer> .Swap(this.TOC.VisibleLayers); } } else { layers = new List <ILayer>(); foreach (IDatasetElement layer in this.MapElements) { if (!(layer is ILayer)) { continue; } if (((ILayer)layer).Visible) { layers.Add((ILayer)layer); } } } if (BeforeRenderLayers != null) { // // Kopie der Original Layer erstellen // ACHTUNG: Renderer werden nicht kopiert! // dürfen in BeforeRenderLayers nicht verändert werden... // Eine zuweisung eines neuen Renderers ist jedoch legitim. // List <ILayer> modLayers = new List <ILayer>(); foreach (IDatasetElement element in layers) { if (!(element is ILayer) || element is IWebServiceTheme) { continue; } ILayer layer = (ILayer)element; if (layer.MinimumScale > 1 && layer.MinimumScale > this.mapScale) { continue; } if (layer.MaximumScale > 1 && layer.MaximumScale < this.mapScale) { continue; } modLayers.Add(LayerFactory.Create(layer.Class, layer)); } BeforeRenderLayers(this, modLayers); layers = modLayers; } //layers = ModifyLayerList(layers); List <IFeatureLayer> labelLayers = this.OrderedLabelLayers(layers); LabelEngine.Init(this.Display, false); foreach (IDatasetElement element in layers) { if (!cancelTracker.Continue) { break; } if (!(element is ILayer)) { continue; } ILayer layer = (ILayer)element; //if (_ceckLayerVisibilityBeforeDrawing) //{ // if (!LayerIsVisible(layer)) continue; //} if (!layer.Visible) { continue; } if (!layer.RenderInScale(this)) { continue; } #if (DEBUG) //Logger.LogDebug("Drawing Layer:" + element.Title); #endif SetGeotransformer((ILayer)element, geoTransformer); if (layer is IFeatureLayer) { if (layer.Class?.Dataset is IFeatureCacheDataset) { await((IFeatureCacheDataset)layer.Class.Dataset).InitFeatureCache(datasetCachingContext); } IFeatureLayer fLayer = (IFeatureLayer)layer; if (fLayer.FeatureRenderer == null && ( fLayer.LabelRenderer == null || (fLayer.LabelRenderer != null && fLayer.LabelRenderer.RenderMode != LabelRenderMode.RenderWithFeature) )) { //continue; } else { RenderFeatureLayer rlt = new RenderFeatureLayer(this, datasetCachingContext, fLayer, cancelTracker, new FeatureCounter()); if (fLayer.LabelRenderer != null && fLayer.LabelRenderer.RenderMode == LabelRenderMode.RenderWithFeature) { rlt.UseLabelRenderer = true; } else { rlt.UseLabelRenderer = labelLayers.IndexOf(fLayer) == 0; // letzten Layer gleich mitlabeln } if (rlt.UseLabelRenderer) { labelLayers.Remove(fLayer); } await rlt.Render(); } //thread = new Thread(new ThreadStart(rlt.Render)); //thread.Start(); } if (layer is IRasterLayer && ((IRasterLayer)layer).RasterClass != null) { IRasterLayer rLayer = (IRasterLayer)layer; if (rLayer.RasterClass.Polygon == null) { continue; } IEnvelope dispEnvelope = this.Envelope; if (Display.GeometricTransformer != null) { dispEnvelope = ((IGeometry)Display.GeometricTransformer.InvTransform2D(dispEnvelope)).Envelope; } if (gView.Framework.SpatialAlgorithms.Algorithm.IntersectBox(rLayer.RasterClass.Polygon, dispEnvelope)) { if (rLayer.Class is IParentRasterLayer) { await DrawRasterParentLayer((IParentRasterLayer)rLayer.Class, cancelTracker, rLayer); } else { RenderRasterLayer rlt = new RenderRasterLayer(this, rLayer, rLayer, cancelTracker); await rlt.Render(); //thread = new Thread(new ThreadStart(rlt.Render)); //thread.Start(); } } } // Andere Layer (zB IRasterLayer) #if (DEBUG) //Logger.LogDebug("Finished drawing layer: " + element.Title); #endif } // Label Features if (labelLayers.Count != 0) { foreach (IFeatureLayer fLayer in labelLayers) { this.SetGeotransformer(fLayer, geoTransformer); if (!fLayer.Visible) { continue; } RenderLabel rlt = new RenderLabel(this, fLayer, cancelTracker, new FeatureCounter()); await rlt.Render(); } } LabelEngine.Draw(this.Display, cancelTracker); LabelEngine.Release(); if (cancelTracker.Continue) { while (m_imageMerger.Count < m_imageMerger.max) { await Task.Delay(10); } } if (_drawScaleBar) { m_imageMerger.mapScale = this.mapScale; m_imageMerger.dpi = this.dpi; } #if (DEBUG) //Logger.LogDebug("Merge Images"); #endif m_imageMerger.Merge(_bitmap, this.Display); m_imageMerger.Clear(); #if (DEBUG) //Logger.LogDebug("Merge Images Finished"); #endif } if (phase == DrawPhase.All || phase == DrawPhase.Graphics) { foreach (IGraphicElement grElement in Display.GraphicsContainer.Elements) { grElement.Draw(Display); } } base.AppendRequestExceptionsToImage(); if (_canvas != null) { _canvas.Dispose(); } _canvas = null; this.GeometricTransformer = null; } return(this.HasRequestExceptions == false); }
async public Task <bool> Open(IServiceRequestContext context) { if (_class == null) { _class = new GeoServicesClass(this); } _class.Themes.Clear(); _themes = new List <IWebServiceTheme>(); string serviceUrl = ServiceUrl(); string user = ConfigTextStream.ExtractValue(ConnectionString, "user"); string pwd = ConfigTextStream.ExtractValue(ConnectionString, "pwd"); var jsonMapService = await TryPostAsync <JsonMapService>($"{serviceUrl}?f=json"); var jsonLayers = await TryPostAsync <JsonLayers>($"{serviceUrl}/layers?f=json"); if (jsonMapService != null) { _class.Name = jsonMapService.MapName; if (jsonMapService.FullExtent != null) { _class.Envelope = new Envelope( jsonMapService.FullExtent.XMin, jsonMapService.FullExtent.YMin, jsonMapService.FullExtent.XMax, jsonMapService.FullExtent.YMax); } if (jsonMapService.SpatialReferenceInstance != null && jsonMapService.SpatialReferenceInstance.Wkid > 0) { var sRef = gView.Framework.Geometry.SpatialReference.FromID("epsg:" + jsonMapService.SpatialReferenceInstance.Wkid); this.SetSpatialReference(sRef); _class.SpatialReference = sRef; } if (jsonLayers?.Layers != null) { foreach (var jsonLayer in jsonLayers.Layers) { IClass themeClass = null; IWebServiceTheme theme = null; if (jsonLayer.Type.ToLower() == "feature layer") { themeClass = await GeoServicesFeatureClass.CreateAsync(this, jsonLayer); theme = LayerFactory.Create(themeClass, _class as IWebServiceClass) as IWebServiceTheme; if (theme == null) { continue; } } // ToDo Raster classes if (themeClass == null) { continue; } theme.Visible = true; //false; _class.Themes.Add(theme); } } } return(true); }
public bool Open() { try { _elements.Clear(); string param = "REQUEST=GetCapabilities&VERSION=1.0.0&SERVICE=WFS"; string url = WMSDataset.Append2Url(_url, param); string response = WebFunctions.HttpSendRequest(url, "GET", null); response = WMSDataset.RemoveDOCTYPE(response); XmlDocument doc = new XmlDocument(); doc.LoadXml(response); XmlNamespaceManager ns = new XmlNamespaceManager(doc.NameTable); ns.AddNamespace("WFS", "http://www.opengis.net/wfs"); ns.AddNamespace("OGC", "http://www.opengis.net/ogc"); ns.AddNamespace("GML", "http://www.opengis.net/gml"); XmlNode CapabilitiesNode = doc.SelectSingleNode("WFS:WFS_Capabilities/WFS:Capability", ns); _getCapabilities = new GetCapabilities(CapabilitiesNode.SelectSingleNode("WFS:Request/WFS:GetCapabilities", ns), ns); _decribeFeatureType = new DescribeFeatureType(CapabilitiesNode.SelectSingleNode("WFS:Request/WFS:DescribeFeatureType", ns), ns); _getFeature = new GetFeature(CapabilitiesNode.SelectSingleNode("WFS:Request/WFS:GetFeature", ns), ns); XmlNode FeatureTypeListNode = doc.SelectSingleNode("WFS:WFS_Capabilities/WFS:FeatureTypeList", ns); _operations = new Operations(FeatureTypeListNode.SelectSingleNode("WFS:Operations", ns)); foreach (XmlNode featureTypeNode in FeatureTypeListNode.SelectNodes("WFS:FeatureType", ns)) { string name = ""; string title = ""; XmlNode nameNode = featureTypeNode.SelectSingleNode("WFS:Name", ns); XmlNode titleNode = featureTypeNode.SelectSingleNode("WFS:Title", ns); WMSClass.SRS srs = new WMSClass.SRS(featureTypeNode, ns, "WFS"); name = title = nameNode.InnerText; if (titleNode != null) { title = titleNode.InnerText; } WFSFeatureClass featureClass = new WFSFeatureClass(this, name, srs); //DatasetElement dselement = new DatasetElement(featureClass); ILayer dselement = LayerFactory.Create(featureClass); if (dselement == null) { continue; } dselement.Title = name; _elements.Add(dselement); } _filter_capabilites = new Filter_Capabilities(doc.SelectSingleNode("WFS:WFS_Capabilities/OGC:Filter_Capabilities", ns), ns); return(true); } catch (Exception ex) { string err = ex.Message; return(false); } }
async public Task Render() { if (_layer == null || _map == null) { return; } #region JSON FilterCollection if (_layer.FilterQuery != null && !String.IsNullOrEmpty(_layer.FilterQuery.JsonWhereClause)) { try { DisplayFilterCollection dfc = DisplayFilterCollection.FromJSON(_layer.FilterQuery.JsonWhereClause); if (dfc == null) { return; } IFeatureLayer flayer = (IFeatureLayer)LayerFactory.Create(_layer.Class, _layer); flayer.FilterQuery = (IQueryFilter)_layer.FilterQuery.Clone(); foreach (DisplayFilter df in dfc) { // immer neu klonen (wegen PenWidth...)!! flayer.FeatureRenderer = _layer.FeatureRenderer != null ? (IFeatureRenderer)_layer.FeatureRenderer.Clone() : null; flayer.FilterQuery.WhereClause = df.Filter; if (flayer.FeatureRenderer != null) { foreach (ISymbol symbol in flayer.FeatureRenderer.Symbols) { if (df.Color.A > 0) { if (symbol is IPenColor) { ((IPenColor)symbol).PenColor = df.Color; } if (symbol is IBrushColor) { ((IBrushColor)symbol).FillColor = df.Color; } if (symbol is IFontColor) { ((IFontColor)symbol).FontColor = df.Color; } } if (df.PenWidth > 0f && symbol is IPenWidth) { ((IPenWidth)symbol).PenWidth = df.PenWidth; } } } await Render(flayer); } } catch { } return; } #endregion await Render(_layer); }