private void OnSerializing() { Animator animator = GetComponent<Animator>(); // Store the current state for each layer layerData = new LayerInfo[animator.layerCount]; for (int i = 0; i < animator.layerCount; i++) { layerData[i] = new LayerInfo { index = i, currentHash = animator.GetCurrentAnimatorStateInfo(i).shortNameHash, nextHash = animator.GetNextAnimatorStateInfo(i).shortNameHash, normalizedTimeCurrent = animator.GetCurrentAnimatorStateInfo(i).normalizedTime, normalizedTimeNext = animator.GetNextAnimatorStateInfo(i).normalizedTime, weight = animator.GetLayerWeight(i) }; } // Store every parameter parameterData = new ParameterInfo[animator.parameterCount]; for (int i = 0; i < animator.parameterCount; i++) { parameterData[i] = new ParameterInfo { number = animator.parameters[i].nameHash, type = animator.parameters[i].type, value = GetParameterValue(animator.parameters[i].nameHash, animator.parameters[i].type, animator) }; } }
void Awake () { anim = GetComponent<Animator> (); layerInfo = new LayerInfo[anim.layerCount]; for (int i=0; i<layerInfo.Length; i++) { layerInfo [i] = new LayerInfo (); } }
public FlashAnimation(LayerInfo layer, int x, int y, Color color) { Layer = layer; _x = x; _y = y; _color = color; _frame = 0; }
private LayerInfo WireRenderRequired(LayerInfo info, bool doWire) { if (doWire && info.Layer is ILayerEx layerEx) { layerEx.RenderRequired += HandleRenderRequired; } return(info); }
protected override void Deserialize_02(string[] lines) { int c = 0; this.Layers = SCommon.Serializer.I.Split(lines[c++]) .Select(line => LayerInfo.Deserialize(SCommon.Serializer.I.Split(line))) .ToList(); }
public DlgEqptMaintain(LayerInfo layerInfo, int smId, EqptMaintain eqptMaintain) { InitializeComponent(); _eqptMaintain = eqptMaintain; _layerInfo = layerInfo; _smId = smId; InitForm(); }
private void OnSerializing() { Animator animator = GetComponent <Animator>(); if (storeAllLayers) { // Store the current state for each layer layerData = new LayerInfo[animator.layerCount]; for (int i = 0; i < animator.layerCount; i++) { layerData[i] = new LayerInfo { index = i, currentHash = animator.GetCurrentAnimatorStateInfo(i).shortNameHash, nextHash = animator.GetNextAnimatorStateInfo(i).shortNameHash, normalizedTimeCurrent = animator.GetCurrentAnimatorStateInfo(i).normalizedTime, normalizedTimeNext = animator.GetNextAnimatorStateInfo(i).normalizedTime, weight = animator.GetLayerWeight(i) }; } } else { // Store the current state for each layer we want to store layerData = new LayerInfo[GetStoredLayerCount()]; int li; for (int i = li = 0; i < animator.layerCount; i++) { if ((layerMask[i / 8] >> (i % 8) & 1) == 0) { continue; } layerData[li] = new LayerInfo { index = i, currentHash = animator.GetCurrentAnimatorStateInfo(i).shortNameHash, nextHash = animator.GetNextAnimatorStateInfo(i).shortNameHash, normalizedTimeCurrent = animator.GetCurrentAnimatorStateInfo(i).normalizedTime, normalizedTimeNext = animator.GetNextAnimatorStateInfo(i).normalizedTime, weight = animator.GetLayerWeight(i) }; li++; } } // Store every parameter parameterData = new ParameterInfo[animator.parameterCount]; for (int i = 0; i < animator.parameterCount; i++) { parameterData[i] = new ParameterInfo { number = animator.parameters[i].nameHash, type = animator.parameters[i].type, value = GetParameterValue(animator.parameters[i].nameHash, animator.parameters[i].type, animator) }; } }
public void Draw(LayerInfo layer) { _substates[_index].Draw(layer); _bAbandon.Draw(layer); _bBase.Draw(layer); _bBegin.Draw(layer); _bLoadout.Draw(layer); }
void DrawLayer(int layer, PaintEventArgs e, bool trans) { LayerInfo li = map.get_LayerInfo(layer); // parallax int xw = (int)(1.0 * xwin * li.pmulx / li.pdivx); int yw = (int)(1.0 * ywin * li.pmuly / li.pdivy); // Only drawing the specified rect. Dirty rectangles are fast. :D xw += e.ClipRectangle.Left; yw += e.ClipRectangle.Top; // first tile to be drawn int xtile = xw / tiles.Width; int ytile = yw / tiles.Height; // where to draw that first tile int xadj = -(xw % tiles.Width); int yadj = -(yw % tiles.Height); // How many tiles to draw on each axis int xlen = e.ClipRectangle.Width / tiles.Width + 2; int ylen = e.ClipRectangle.Height / tiles.Height + 2; // Clip if (xtile + xlen > map.Width) { xlen = map.Width - xtile; } if (ytile + ylen > map.Height) { ylen = map.Height - ytile; } // now we loop, and draw int xt = xtile; // need this later for (int y = 0; y < ylen; y++) { for (int x = 0; x < xlen; x++) { int t = map.get_Tile(xtile, ytile, layer); if (trans && t == 0) { xtile++; continue; } e.Graphics.DrawImage(tiles[t], x * tiles.Width + xadj, y * tiles.Height + yadj); xtile++; } ytile++; xtile = xt; } }
void Awake() { anim = GetComponent <Animator> (); layerInfo = new LayerInfo[anim.layerCount]; for (int i = 0; i < layerInfo.Length; i++) { layerInfo [i] = new LayerInfo(); } }
private void DefineArchitecture(out LayerInfo[] architecture) { architecture = new LayerInfo[NumberOfLayers]; architecture[0] = new LayerInfo(1, NumberOfRules * Instance.NumVariables, NeuronType.Input); architecture[1] = new LayerInfo(Instance.NumVariables, NumberOfRules, NeuronType.Multiplication); architecture[2] = new LayerInfo(NumberOfRules, NumberOfRules, NeuronType.Normalization); architecture[3] = new LayerInfo(1, NumberOfRules, NeuronType.Function); architecture[4] = new LayerInfo(NumberOfRules, 1, NeuronType.Output); }
/// <summary> /// Применить изменение на хранилище /// </summary> public StateStorage Apply(StateStorage storage, LayerInfo layer) { switch (layer.ChangeType) { case WatcherChangeTypes.Deleted: storage.FilesData.Remove(Path.Combine(layer.RelativePath, layer.FileName)); break; case WatcherChangeTypes.Renamed: storage.FilesData.Add( Path.Combine(layer.RelativePath, layer.NewName), storage.FilesData[Path.Combine(layer.RelativePath, layer.FileName)] ); storage.FilesData.Remove(Path.Combine(layer.RelativePath, layer.FileName)); break; case WatcherChangeTypes.Changed: var key = Path.Combine(layer.RelativePath, layer.FileName); if (!storage.FilesData.ContainsKey(key)) { storage.FilesData.Add(key, new StorageData() { Name = layer.FileName, Relative = layer.RelativePath, Text = layer.AddOrUpdateData.ChangesRows .Select(e => e.Content) .ToArray() }); } else { var item = storage.FilesData[key]; var rows = new List <string>(item.Text); foreach (var elem in layer.AddOrUpdateData.ChangesRows) { if (elem.RowNumber < rows.Count - 1) { rows[elem.RowNumber] = elem.Content; } else { rows.Add(elem.Content); } } item.Text = rows .Take(layer.AddOrUpdateData.LastRowNumber) .ToArray(); } break; } return(storage); }
public void DepthNodeReorderTest() { var metaNeatGenome = new MetaNeatGenome <double>(2, 2, true, new ReLU()); var genomeBuilder = NeatGenomeBuilderFactory <double> .Create(metaNeatGenome); // Define graph connections. var connGenes = new ConnectionGenes <double>(5); connGenes[0] = (0, 4, 0.0); connGenes[1] = (4, 5, 1.0); connGenes[2] = (5, 2, 2.0); connGenes[3] = (1, 2, 3.0); connGenes[4] = (2, 3, 4.0); connGenes.Sort(); // Wrap in a genome. var genome = genomeBuilder.Create(0, 0, connGenes); // Note. The genome builder creates a digraph representation of the genome and attaches/caches it on the genome object. var acyclicDigraph = (DirectedGraphAcyclic)genome.DirectedGraph; Assert.NotNull(acyclicDigraph); // Simulate the actual weight array that would occur in e.g. a WeightedDirectedGraphAcyclic or NeuralNetAcyclic. double[] weightArrActual = new double[connGenes._weightArr.Length]; for (int i = 0; i < weightArrActual.Length; i++) { weightArrActual[i] = connGenes._weightArr[genome.ConnectionIndexMap[i]]; } // The nodes should have IDs allocated based on depth, i.e. the layer they are in. // And connections should be ordered by source node ID. var connArrExpected = new DirectedConnection[5]; var weightArrExpected = new double[5]; connArrExpected[0] = new DirectedConnection(0, 2); weightArrExpected[0] = 0.0; connArrExpected[1] = new DirectedConnection(1, 4); weightArrExpected[1] = 3.0; connArrExpected[2] = new DirectedConnection(2, 3); weightArrExpected[2] = 1.0; connArrExpected[3] = new DirectedConnection(3, 4); weightArrExpected[3] = 2.0; connArrExpected[4] = new DirectedConnection(4, 5); weightArrExpected[4] = 4.0; // Compare actual and expected connections. CompareConnectionLists(connArrExpected, weightArrExpected, acyclicDigraph.ConnectionIds, weightArrActual); // Test layer info. LayerInfo[] layerArrExpected = new LayerInfo[5]; layerArrExpected[0] = new LayerInfo(2, 2); layerArrExpected[1] = new LayerInfo(3, 3); layerArrExpected[2] = new LayerInfo(4, 4); layerArrExpected[3] = new LayerInfo(5, 5); layerArrExpected[4] = new LayerInfo(6, 5); Assert.Equal(5, acyclicDigraph.LayerArray.Length); // Check the node count. Assert.Equal(6, acyclicDigraph.TotalNodeCount); }
/// <summary> /// 更新层级信息 /// </summary> /// <param name="layerInfo"></param> /// <param name="newLayerInfo"></param> private void UpdateLayerInfo(LayerInfo layerInfo, LayerInfo newLayerInfo) { layerInfo.path = newLayerInfo.path; layerInfo.rect = newLayerInfo.rect; UpdateResourceDic(layerInfo.resourceDic, newLayerInfo.resourceDic); UpdateSubResourceDic(layerInfo.subResourceDic, newLayerInfo.subResourceDic); UpdateDicArray("new Image", layerInfo.sub_images, newLayerInfo.sub_images); UpdateDicArray("new Text", layerInfo.sub_texts, newLayerInfo.sub_texts); UpdateDicArray("new RawImage", layerInfo.sub_rawImages, newLayerInfo.sub_rawImages); }
protected BaseLayer(LayerInfo info) { InputShape = new Shape(info.InputShape.B, info.InputShape.C, info.InputShape.H, info.InputShape.W); OutputShape = new Shape(info.OutputShape.B, info.OutputShape.C, info.OutputShape.H, info.OutputShape.W); Builder = TensorBuilder.Create(); Output = Builder.Empty(); InputGradient = Builder.Empty(); IsInit = true; }
public Tile(LayerInfo layerInfo, WorldAnchor anchor) : base(layerInfo.width, layerInfo.height, anchor) { if (layerInfo == null) { Debug.LogError("must not be null"); } this.tileInfo = layerInfo; }
private void InitLayers() { this.tileMapLayers = new List<LayerInfo>(); LayerInfo item = new LayerInfo(); item = new LayerInfo(); item.name = "Layer 0"; item.hash = 0x70d32b98; item.z = 0f; this.tileMapLayers.Add(item); }
public void Draw() { if (_states.Count == 0) return; IState current = _states.Peek(); LayerInfo info = _consoles[current.GetType()]; Terminal.Layer(info.Z); current.Draw(info); }
public void InsetItem(int index, string name, string path, string type, Rect rect) { var layerInfo = new LayerInfo(); layerInfo.name = name; layerInfo.path = path; layerInfo.type = type; layerInfo.rect = rect; CreateNewLayerInternal(index, layerInfo); }
/// <summary> /// 获得相机的友好视角轴 /// </summary> /// <returns></returns> public int GetFirendlyCameraDirection(int x, int y, int z) { try { LayerInfo now = _layerinfos[z]; return(now.DirectionMap[x]); } catch { return(0); } }
public virtual LayerInfo GetLayerInfo() { var layerInfo = new LayerInfo { LayerType = GetType().FullName, InputShape = new ShapeInfo(InputShape), OutputShape = new ShapeInfo(OutputShape) }; return(layerInfo); }
internal void Draw(LayerInfo layer, Loc pos, Color color) { Terminal.Layer(2); foreach (Part p in PartList) { Terminal.Color(p.Invalid ? Color.Red : color); p.Draw(layer, pos); } Terminal.Layer(1); }
/// <summary> /// 通过预定义序号获得模型坐标 /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="z"></param> /// <returns></returns> public Vector3 GetPosition(int x, int y, int z) { try { LayerInfo now = _layerinfos[z]; Vector2Int key = new Vector2Int(x, y); return(new Vector3(now[key].x, _cameraheight, now[key].y)); } catch { return(Vector3.zero); } }
public HookAnimation(LayerInfo layer, Actor source, IEnumerable <Loc> path, bool retract, Actor target = null) { Layer = layer; _source = source; _path = path.ToList(); _retract = retract; _target = target; _counter = 0; _hit = false; }
private void btnPlanningConclusionShow_Click(object sender, EventArgs e) { try { string layerName = ""; //图层名称 ButtonItem bi = (ButtonItem)sender; switch (bi.Name) { case "btnAddNewLayer": CommonBaseTool.GISBrowseTools.AddLayerToGlobe(this.axGlobeControl1); break; //辽宁沿海经济带地图 case "btnLiaoningBySea": layerName = "btn_" + "市区"; break; //海域范围 case "btnHaiyufanwei": layerName = "btn_" + "海域范围"; break; //生态安全战略 case "btnShengtaianquan": layerName = "btn_" + "生态安全战略P"; break; //生态综合整治 case "btnShengtaizhengzhi": layerName = "btn_" + "生态综合整治"; break; //矿产资源分布 case "btnKuangchanziyuan": layerName = "btn_" + "矿产"; break; //景点分布 case "btnJingdianfenbu": layerName = "btn_" + "景点"; break; } LayerInfo layerInfo = LayerNameList.Find(delegate(LayerInfo li) { return(li.LayerName == layerName); }); if (layerInfo.LayerName == null || layerInfo.LayerName == "") { return; } pSceneBookmark.ZoomToScene("全省视图"); CommonBaseTool.BaseGISTools.ShowLayerOrNot(this.axGlobeControl1, LayerNameList, layerName, bi.Checked); } catch { } }
public static void RegisterLayer(ILayer layer) { string TypeName = layer.GetType().FullName; layers[TypeName] = layer; LayerInfo info = layer.GetInfo(); names[TypeName] = info.Name; icons[TypeName] = ModLoader.GetTexture(info.Texture); }
public ZeroPaddingLayer(LayerInfo info) : base(info) { var padLayerInfo = info as PaddingLayerInfo; if (padLayerInfo == null) { throw new ArgumentException(nameof(info)); } Padding = padLayerInfo.Padding; }
public override bool Equals(object obj) { if (!(obj is LayerInfo)) { return(false); } LayerInfo mys = (LayerInfo)obj; return(mys.InputSize == InputSize && mys.NumberOfNeurons == NumberOfNeurons && mys.Type == Type); }
public void LoadLayerToc(LayerInfo layer, bool includeImages) { if (layer.Type == LayerType.FeatureClass) { layer.Toc = new Toc(LoadTocGroups(layer.Renderer, _swatchMaker, includeImages)); } else { layer.Toc = new Toc(); } }
/// <summary> /// Gets whether a sub-layer is visible in the map based on the sub-layer's scale dependency /// and the map's current scale /// </summary> internal static bool IsInVisibleRange(this LayerInfo subLayer, Map map) { if (map == null) { return(true); // No map, so scale dependency is N/A } bool isBeyondMaxScale = !double.IsInfinity(subLayer.MaxScale) && subLayer.MaxScale > map.Scale; bool isBeyondMinScale = subLayer.MinScale > 0 && subLayer.MinScale < map.Scale; return(!isBeyondMaxScale && !isBeyondMinScale); }
public override void Draw(LayerInfo layer) { base.Draw(layer); if (_fromSubinv) { Game.Player.Inventory.DrawStackSelected(layer, _subinvKey, Selected); } LayerInfo itemMenu = new LayerInfo("Item menu", layer.Z + 1, layer.X + 0, layer.Y + Line + 2, 9, 4); itemMenu.Clear(); Terminal.Color(Colors.HighlightColor); itemMenu.DrawBorders(new BorderInfo { TopLeftChar = '╠', // 204 TopRightChar = '╗', // 187 BottomLeftChar = '╠', BottomRightChar = '╝', // 188 TopChar = '═', // 205 BottomChar = '═', LeftChar = '║', // 186 RightChar = '║' }); if (_usable) { Terminal.Color(Colors.HighlightColor); itemMenu.Print(0, 0, "(a)[color=white]pply"); } else { Terminal.Color(Colors.DimText); itemMenu.Print(0, 0, "(a)pply"); } // TODO: check edibility Terminal.Color(Colors.DimText); itemMenu.Print(0, 1, "(c)onsume"); Terminal.Color(Colors.HighlightColor); itemMenu.Print(0, 2, "(t)[color=white]hrow"); if (_equippable) { Terminal.Color(Colors.HighlightColor); itemMenu.Print(0, 3, "(w)[color=white]ear"); } else { Terminal.Color(Colors.DimText); itemMenu.Print(0, 3, "(w)ear"); } }
/// <summary> /// Checkes whether a sub-layer (LayerInfo) is in a measurable state /// </summary> /// <param name="subLayer">The sub-layer to check</param> /// <param name="parentLayer">The map service layer containing the sub-layer</param> /// <param name="map">The map containing the map service layer</param> /// <returns>True if the sub-layer is measurable, false if not</returns> internal static bool IsMeasurable(this LayerInfo subLayer, ArcGISDynamicMapServiceLayer parentLayer, Map map) { if (parentLayer.VisibleLayers == null) { return(subLayer.DefaultVisibility && subLayer.IsInVisibleRange(map)); } else { return(parentLayer.VisibleLayers.Contains(subLayer.ID) && subLayer.IsInVisibleRange(map)); } }
/// <override></override> protected override void OnAfterLabelEdit(LabelEditEventArgs e) { base.OnAfterLabelEdit(e); enableRenameLayer = false; newName = e.Label; if (newName != null && oldName != newName && LayerRenamed != null) { LayerInfo layerInfo = (LayerInfo)Items[e.Item].Tag; LayerRenamed(this, new LayerRenamedEventArgs(layerInfo.layer, oldName, newName)); } oldName = newName = string.Empty; }
public void Draw(LayerInfo layer) { foreach ((int _, List <IAnimation> queue) in _current) { IAnimation animation = queue.FirstOrDefault(); if (animation != null) { animation.Draw(layer); } } }
public TileLayer(CameraBox cameraBox, float depth, float y, LayerInfo layerInfo) : base(cameraBox, depth) { if (layerInfo == null) { Debug.LogError("must not be null"); } // ddong float cameraWidth = 16; float playerLayerOffsetX = cameraBox.GetLayer(0).coord.ZeroInBoxPoint.x; this.initX = -playerLayerOffsetX * layerInfo.speed - cameraWidth; this.initY = y; this.layerInfo = layerInfo; do { AddNewTile(); } while (lastGenRect.BottomRight.InBoxPoint.x < cameraWidth); }
public IEnumerable MapFromReader(IDataReader reader, SelectClause selectClause) { var successRead = reader.Read(); LayerInfo firstLayer = null; LayerInfo lastLayer = null; foreach (var selectPart in selectClause.Parts) { var typePart = selectPart as TypePart; if (typePart != null) { var layer = new LayerInfo { TypePart = typePart, CreatingDelegate = GetTypeInstanceCreateDelegate(typePart.Type), FillingDelegates = typePart.Tables.Select(z => GetFiller(typePart.Type, z)).ToList(), }; if (lastLayer != null) lastLayer.AddNextLayer(layer); if (firstLayer == null) firstLayer = layer; lastLayer = layer; } else { var expansion = selectPart as ExpansionPart; if (expansion != null) { if(lastLayer == null) throw new InvalidOperationException("No last layer. Primitives can't be first"); if(lastLayer.TypePart.Type != expansion.CollectingType) throw new InvalidOperationException("Implementation accepts only collections for previous type's properties"); lastLayer.Expansions.Add(expansion); } } } while (successRead) { yield return LoadObjectTree(firstLayer, reader, out successRead); } }
private static List<LayerWrapper> LoadChainFromSeedLayers( string appName, List<LayerSeed> layers, List<Dictionary<string,object>> parameters) { var chain = new List<LayerWrapper>(); for(int i = 0; i < layers.Count; i++) { LayerSeed layer = layers[i]; var param = parameters[i]; LayerInfo info = new LayerInfo(null, layer.Seed.Name, param); LayerWrapper toadd = layer.CreateLayerFromSeed( appName, info, i); chain.Add(toadd); } return chain; }
public void initMlp(LayerInfo[] layerInfo) { layers = new List<Layer>(); int numi = layerInfo[0].numOfNeurons; inputLayer = new Layer("I", numi + 1, Layer.LAYER_INPUT); // plus the bias int numo = layerInfo[layerInfo.Length - 1].numOfNeurons; outputLayer = new Layer("O", numo, Layer.LAYER_OUTPUT); layers.Add(inputLayer); layers.Add(outputLayer); // creo gli Hidden Layer if (layerInfo.Length > 2) { for (int i = 1; i < (layerInfo.Length - 1); i++) { int num_neuron = layerInfo[i].numOfNeurons; addHiddenLayer(num_neuron, "H" + i); } this.connectAllLayers(); } else try { connectTwoLayers(inputLayer, outputLayer); } catch (System.Exception e) { Console.Error.WriteLine(e.StackTrace); } error = 10.0; }
private void ParseCapabilities(XDocument xDoc) { string ns = xDoc.Root.Name.NamespaceName; if (xDoc.Root.Attribute("version") != null) Version = xDoc.Root.Attribute("version").Value; //Get service info var info = (from Service in xDoc.Descendants(XName.Get("Service", ns)) select new { Title = Service.Element(XName.Get("Title", ns)) == null ? null : Service.Element(XName.Get("Title", ns)).Value, Abstract = Service.Element(XName.Get("Abstract", ns)) == null ? null : Service.Element(XName.Get("Abstract", ns)).Value }).First(); if (info != null) { this.Title = info.Title; //OnPropertyChanged("Title"); this.Abstract = info.Abstract; //OnPropertyChanged("Abstract"); } //Get a list of layers var capabilities = xDoc.Descendants(XName.Get("Capability", ns)).FirstOrDefault(); var layerList = CreateLayerInfos(capabilities, ns, null); rootLayer = layerList.FirstOrDefault(); // Give a subLayerID to all layers int subLayerID = 0; foreach (var layerInfo in Descendants(LayerList)) layerInfo.SubLayerID = subLayerID++; // Init Visibility from the list of Layers SetVisibleLayers(); try { //Get endpoint for GetMap requests var request = (from c in capabilities.Descendants(XName.Get("Request", ns)) select c).First(); var GetMaps = (from c in request.Descendants(XName.Get("GetMap", ns)) select c); var GetMap = (from c in GetMaps where c.Descendants(XName.Get("Format", ns)).Select(t => (t.Value == "image/png" || t.Value == "image/jpeg")).Count() > 0 select c).First(); var formats = (from c in GetMaps.Descendants(XName.Get("Format", ns)) select c); //Silverlight only supports png and jpg. Prefer PNG, then JPEG SupportedImageFormats = new ReadOnlyCollection<string>(new List<string>(from c in formats where c.Value != null select c.Value)); OnPropertyChanged("SupportedImageFormats"); if (ImageFormat == null) { foreach (string f in new string[] { "image/png", "image/jpeg", "image/jpg" #if !SILVERLIGHT //for WPF after PNG and JPEG, Prefer GIF, then any image, then whatever is supported ,"image/gif","image/" #endif }) { ImageFormat = (from c in SupportedImageFormats where c.StartsWith(f) select c).FirstOrDefault(); if (ImageFormat != null) break; } #if !SILVERLIGHT if(ImageFormat == null) ImageFormat = (from c in formats where c.Value != null select c.Value).FirstOrDefault(); #endif } var DCPType = (from c in GetMap.Descendants(XName.Get("DCPType", ns)) select c).First(); var HTTP = (from c in DCPType.Descendants(XName.Get("HTTP", ns)) select c).First(); var Get = (from c in HTTP.Descendants(XName.Get("Get", ns)) select c).First(); var OnlineResource = (from c in Get.Descendants(XName.Get("OnlineResource", ns)) select c).First(); var href = OnlineResource.Attribute(XName.Get("href", "http://www.w3.org/1999/xlink")); if (this.MapUrl == null) this.MapUrl = href.Value; } catch { //Default to WMS url if (this.MapUrl == null) this.MapUrl = this.Url; } bool lowerThan13 = LowerThan13Version(); List<int> supportedIDs = new List<int>(); string key = lowerThan13 ? "SRS" : "CRS"; IEnumerable<XElement> SRSs = xDoc.Descendants(XName.Get(key, ns)); foreach (var element in SRSs) { if (element.Value != null && element.Value.StartsWith("EPSG:")) { try { int srid = int.Parse(element.Value.Replace("EPSG:", ""), CultureInfo.InvariantCulture); if (!supportedIDs.Contains(srid)) supportedIDs.Add(srid); } catch { } } } SupportedSpatialReferenceIDs = supportedIDs.ToArray(); //Get the full extent of all layers IEnumerable<XElement> elements = xDoc.Descendants(XName.Get("BoundingBox", ns)); if (!elements.GetEnumerator().MoveNext() && lowerThan13) { var element = xDoc.Descendants(XName.Get("LatLonBoundingBox", ns)).First(); this.SpatialReference = new Geometry.SpatialReference(4326); this.FullExtent = GetEnvelope(element, this.SpatialReference, true); } if (this.SpatialReference == null) { foreach (var element in elements) { if (element.Attribute(key) != null && element.Attribute(key).Value.StartsWith("EPSG:")) { try { int srid = int.Parse(element.Attribute(key).Value.Replace("EPSG:", ""), CultureInfo.InvariantCulture); this.SpatialReference = new Geometry.SpatialReference(srid); } catch { } this.FullExtent = GetEnvelope(element, this.SpatialReference, lowerThan13); break; } } if (this.FullExtent == null) //EPSG code not found. Default to first CRS { var element = elements.First(); if (element.Attribute(key) != null) { string value = element.Attribute(key).Value; int idx = value.LastIndexOf(":"); if (idx > -1) value = value.Substring(idx); try { int srid = int.Parse(value, CultureInfo.InvariantCulture); this.SpatialReference = new SpatialReference(srid); } catch { } } this.FullExtent = GetEnvelope(element, this.SpatialReference, lowerThan13); } } }
public void AddNextLayer(LayerInfo layer) { NextLayer = layer; layer.LayerOffset = LayerEnds + Expansions.Sum(z => z.Table.Columns.Count); }
public LayerWrapper CreateLayerFromSeed(string chainName, LayerInfo info, int layerIndex) { Layer toAdd = CopyLayer( Seed); string buildDate = GetLayerBuildDate(LayerDllLocation); try { Dictionary<string, object> parameters = info.Parameters; string intentFilename = chainName + "_" + info.Name + "_" + layerIndex; IRuntimeStorage intent = RuntimeStorage.FromCouchDb(intentFilename); parameters.Add("intent", intent); parameters.Add("shared", sharedLayerData); toAdd.Init(parameters); IEnumerable<string> libnames = toAdd.AnnotationLibraries(); LayerWrapper wrapper = new LayerWrapper(toAdd, parameters, intent, buildDate); return wrapper; } catch (IOException e) { Console.WriteLine("Could not load layer: " + info.Name); Console.WriteLine("Error Message: " + e.Message); Console.WriteLine("Stack Trace: " + e.StackTrace); return null; } }
private void BuildLayersAttribution(LayerInfo layerInfo) { if (Layers == null) return; if (Layers.Contains(layerInfo.Name)) { string parentAttribution = layerInfo.Attribution == null ? null : layerInfo.Attribution.Title; foreach (var child in Descendants(layerInfo.ChildLayers)) { string attribution = child.Attribution == null ? null : child.Attribution.Title; if (!string.IsNullOrEmpty(attribution) && !copyrightText.Contains(attribution)) copyrightText.Add(attribution); } if (!string.IsNullOrEmpty(parentAttribution) && !copyrightText.Contains(parentAttribution)) copyrightText.Add(parentAttribution); } else if (layerInfo.ChildLayers != null) { foreach (var child in layerInfo.ChildLayers) { BuildLayersAttribution(child); } } }
/// <summary> /// Creates the layer info from the layer XElement. /// </summary> /// <param name="layer">The layer XElement.</param> /// <param name="ns">The namespace name.</param> /// <param name="inheritedAttribution">The inherited attribution.</param> /// <returns></returns> private LayerInfo CreateLayerInfo(XElement layer, string ns, string inheritedAttribution = "") { LayerInfo layerInfo = new LayerInfo(); layerInfo.Name = layer.Element(XName.Get("Name", ns)) == null ? null : layer.Element(XName.Get("Name", ns)).Value; layerInfo.Title = layer.Element(XName.Get("Title", ns)) == null ? null : layer.Element(XName.Get("Title", ns)).Value; layerInfo.Abstract = layer.Element(XName.Get("Abstract", ns)) == null ? null : layer.Element(XName.Get("Abstract", ns)).Value; layerInfo.Attribution = new AttributionInfo(); var attribution = layer.Element(XName.Get("Attribution", ns)) == null ? null : layer.Element(XName.Get("Attribution", ns)); if (attribution != null) layerInfo.Attribution.Title = attribution.Element(XName.Get("Title", ns)) == null ? inheritedAttribution : attribution.Element(XName.Get("Title", ns)).Value; else layerInfo.Attribution.Title = inheritedAttribution; bool lowerThan13 = LowerThan13Version(); var extentElement = layer.Element(XName.Get("BoundingBox", ns)); if (extentElement != null) { layerInfo.Extent = GetEnvelope(extentElement, lowerThan13); } layerInfo.ChildLayers = CreateLayerInfos(layer, ns, layerInfo.Attribution.Title); // recursive call for sublayers var style = layer.Element(XName.Get("Style", ns)); if (style != null) { foreach (var legendUrl in style.Elements(XName.Get("LegendURL", ns))) { var format = legendUrl.Element(XName.Get("Format", ns)); var onlineResource = legendUrl.Element(XName.Get("OnlineResource", ns)); if (format != null && onlineResource != null) { #if SILVERLIGHT if (format.Value != "image/png" && format.Value != "image/jpeg" && format.Value != "image/jpeg") continue; #endif var href = onlineResource.Attribute(XName.Get("href", "http://www.w3.org/1999/xlink")); if (href != null) { layerInfo.LegendUrl = href.Value; break; } } } } if (lowerThan13) { // Deal with ScaleHint var scaleHint = layer.Element(XName.Get("ScaleHint", ns)); if (scaleHint != null) { var attribute = scaleHint.Attribute(XName.Get("max", ns)); if (attribute != null) { double value; double.TryParse(attribute.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out value); layerInfo.MinimumScale = ScaleHintToScale(value); } attribute = scaleHint.Attribute(XName.Get("min", ns)); if (attribute != null) { double value; double.TryParse(attribute.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out value); layerInfo.MaximumScale = ScaleHintToScale(value); } } } else { // deal with ScaleDenominator from 1.3.0 var minScaleDenominator = layer.Element(XName.Get("MinScaleDenominator", ns)); if (minScaleDenominator != null) { double value; double.TryParse(minScaleDenominator.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out value); layerInfo.MaximumScale = value; } var maxScaleDenominator = layer.Element(XName.Get("MaxScaleDenominator", ns)); if (maxScaleDenominator != null) { double value; double.TryParse(maxScaleDenominator.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out value); layerInfo.MinimumScale = value; } } return layerInfo; }
private void ParseCapabilities(XDocument xDoc) { string ns = xDoc.Root.Name.NamespaceName; if (xDoc.Root.Attribute("version") != null) Version = xDoc.Root.Attribute("version").Value; //Get service info var info = (from Service in xDoc.Descendants(XName.Get("Service", ns)) select new { Title = Service.Element(XName.Get("Title", ns)) == null ? null : Service.Element(XName.Get("Title", ns)).Value, Abstract = Service.Element(XName.Get("Abstract", ns)) == null ? null : Service.Element(XName.Get("Abstract", ns)).Value }).First(); if (info != null) { this.Title = info.Title; //OnPropertyChanged("Title"); this.Abstract = info.Abstract; //OnPropertyChanged("Abstract"); } //Get a list of layers var capabilities = xDoc.Descendants(XName.Get("Capability", ns)).FirstOrDefault(); var layerList = CreateLayerInfos(capabilities, ns, null); rootLayer = layerList.FirstOrDefault(); // Give a subLayerID to all layers int subLayerID = 0; foreach (var layerInfo in Descendants(LayerList)) layerInfo.SubLayerID = subLayerID++; // Init Visibility from the list of Layers SetVisibleLayers(); try { //Get endpoint for GetMap requests var request = (from c in capabilities.Descendants(XName.Get("Request", ns)) select c).First(); var GetMaps = (from c in request.Descendants(XName.Get("GetMap", ns)) select c); var GetMap = (from c in GetMaps where c.Descendants(XName.Get("Format", ns)).Select(t => (t.Value == "image/png" || t.Value == "image/jpeg")).Count() > 0 select c).First(); var formats = (from c in GetMaps.Descendants(XName.Get("Format", ns)) select c); //Silverlight only supports png and jpg. Prefer PNG, then JPEG SupportedImageFormats = new ReadOnlyCollection<string>(new List<string>(from c in formats where c.Value != null select c.Value)); OnPropertyChanged("SupportedImageFormats"); if (ImageFormat == null) { foreach (string f in new string[] { "image/png", "image/jpeg", "image/jpg" #if !SILVERLIGHT //for WPF after PNG and JPEG, Prefer GIF, then any image, then whatever is supported ,"image/gif","image/" #endif }) { ImageFormat = (from c in SupportedImageFormats where c.StartsWith(f) select c).FirstOrDefault(); if (ImageFormat != null) break; } #if !SILVERLIGHT if(ImageFormat == null) ImageFormat = (from c in formats where c.Value != null select c.Value).FirstOrDefault(); #endif } var DCPType = (from c in GetMap.Descendants(XName.Get("DCPType", ns)) select c).First(); var HTTP = (from c in DCPType.Descendants(XName.Get("HTTP", ns)) select c).First(); var Get = (from c in HTTP.Descendants(XName.Get("Get", ns)) select c).First(); var OnlineResource = (from c in Get.Descendants(XName.Get("OnlineResource", ns)) select c).First(); var href = OnlineResource.Attribute(XName.Get("href", "http://www.w3.org/1999/xlink")); if (this.MapUrl == null) this.MapUrl = href.Value; } catch { //Default to WMS url if (this.MapUrl == null) this.MapUrl = this.Url; } bool lowerThan13 = LowerThan13Version(); List<int> supportedIDs = new List<int>(); string key = lowerThan13 ? "SRS" : "CRS"; IEnumerable<XElement> SRSs = xDoc.Descendants(XName.Get(key, ns)); _useCrsFormat = new List<int>{4326, 4269, 4267}; // initialize with all wkid that supports crs and remove from the list when an EPSG:xxxx format is supported (prefered format for backward compatibility reason) foreach (var element in SRSs) { string value = element.Value; if (value == "EPSG:4326") _useCrsFormat.Remove(4326); else if (value == "EPSG:4269") _useCrsFormat.Remove(4269); else if (value == "EPSG:4267") _useCrsFormat.Remove(4267); var sref = GetSpatialReference(value); if (sref != null && !supportedIDs.Contains(sref.WKID)) supportedIDs.Add(sref.WKID); } SupportedSpatialReferenceIDs = supportedIDs.ToArray(); //Get the full extent of all layers IEnumerable<XElement> elements = xDoc.Descendants(XName.Get("BoundingBox", ns)); if (elements.Any()) { FullExtent = GetEnvelope(elements.First(), lowerThan13); if (FullExtent != null) SpatialReference = FullExtent.SpatialReference; } else if (lowerThan13) { // Get Extent from former "LatLonBoundingBox" element var element = xDoc.Descendants(XName.Get("LatLonBoundingBox", ns)).First(); SpatialReference = new SpatialReference(4326); FullExtent = GetEnvelope(element, true); if (FullExtent != null) FullExtent.SpatialReference = SpatialReference; } }
void AddTileLayer(int depth, LayerInfo layerInfo) { layerInfos[depth] = layerInfo; AddLayer(depth, new TileLayer(this, depth, 0, layerInfo)); GetLayer(depth).SetGuideEnable(false); }
/// <summary> /// Updates the <see cref="MeasurableSubLayers"/> property based on the state of the sub-layers within /// the current <see cref="MeasureLayer"/>. Will also update <see cref="MeasureSubLayer"/> if the /// current one is in an unmeasurable state. /// </summary> private void UpdateMeasurableSubLayers() { // Dynamic map service layer containing sub-layers ArcGISDynamicMapServiceLayer parentLayer = (ArcGISDynamicMapServiceLayer)MeasureLayer; // index of the current measure sub-layer among the map service's sub-layers int indexInMapService = parentLayer.Layers.IndexOf(MeasureSubLayer); // index of the measure sub-layer among the set of measurable sub-layers int indexInMeasurableLayers = MeasurableSubLayers.IndexOf(MeasureSubLayer); // index to insert newly measurable sub-layers int insertIndex = indexInMeasurableLayers + 1; // tracks whether the current measure sub-layer has become unmeasurable bool needsMeasureLayerUpdate = !MeasureSubLayer.IsMeasurable(parentLayer, Map); // Iterate through the sub-layers in the parent map service that are after // the current measure sub-layer for (int i = indexInMapService + 1; i < parentLayer.Layers.Length; i++) { // Get the sub-layer at the current loop index LayerInfo subLayer = parentLayer.Layers[i]; // Get whether the loop sub-layer is measurable and is already a member // of the measurable sub-layers collection bool isMeasurable = subLayer.IsMeasurable(parentLayer, Map); bool isInCollection = MeasurableSubLayers.Contains(subLayer); if (isMeasurable && !isInCollection) // sub-layer is measurable but not in { // collection, so it needs to be added. MeasurableSubLayers.Insert(insertIndex, subLayer); if (needsMeasureLayerUpdate) // check whether a new measure sub-layer needs to be selected { // Update the measure sub-layer and reset the update flag MeasureSubLayer = subLayer; needsMeasureLayerUpdate = false; } insertIndex++; // Increment the insertion index so the next sub-layer is inserted // after this one } else if (!isMeasurable && isInCollection) // sub-layer in collection has become { // unmeasurable, so it needs to be removed MeasurableSubLayers.Remove(subLayer); } else if (isMeasurable && isInCollection) // sub-layer is measurable and already in { // collection. if (needsMeasureLayerUpdate) { MeasureSubLayer = subLayer; // Update the sub-layer if necessary and needsMeasureLayerUpdate = false; // reset the update flag. } insertIndex++; // Increment insertion index so the next one } // gets inserted after this one. } insertIndex = indexInMeasurableLayers; // Iterate through the sub-layers in the parent map service that are before the current // measure sub-layer, looping through them in reverse order for (int i = indexInMapService - 1; i > -1; i--) { // Get the sub-layer at the current loop index LayerInfo subLayer = parentLayer.Layers[i]; // Get whether the loop sub-layer is measurable and is already a member // of the measurable sub-layers collection bool isMeasurable = subLayer.IsMeasurable(parentLayer, Map); bool isInCollection = MeasurableSubLayers.Contains(subLayer); if (isMeasurable && !isInCollection) // sub-layer is measurable but not in { // collection, so it needs to be added. MeasurableSubLayers.Insert(insertIndex, subLayer); if (needsMeasureLayerUpdate) // check whether a new measure sub-layer needs to be selected { // Update the measure sub-layer and reset the update flag MeasureSubLayer = subLayer; needsMeasureLayerUpdate = false; } insertIndex--; // Decrement the insertion index so the next sub-layer is inserted // before this one } else if (!isMeasurable && isInCollection) // sub-layer in collection has become { // unmeasurable, so it needs to be removed MeasurableSubLayers.Remove(subLayer); } else if (isMeasurable && isInCollection) // sub-layer is measurable and already in { // collection. if (needsMeasureLayerUpdate) { MeasureSubLayer = subLayer; // Update the sub-layer if necessary and needsMeasureLayerUpdate = false; // reset the update flag. } insertIndex--; // Decrement insertion index so the next one } // gets inserted before this one. } // Check whether original measure sub-layer needs to be removed if (!parentLayer.Layers[indexInMapService].IsMeasurable(parentLayer, Map)) MeasurableSubLayers.Remove(parentLayer.Layers[indexInMapService]); // If there are no more measurable sub-layers in the current measure layer, update // the list of measurable layers. if (MeasurableSubLayers.Count == 0) UpdateMeasurableLayers(); }
private object LoadObjectTree(LayerInfo layer, IDataReader reader, out bool successRead) { var val = (IComparable)reader.GetValue(layer.LayerOffset); var entityObject = layer.CreatingDelegate(reader, layer.LayerOffset); var notfirst = false; foreach (var fillingDelegate in layer.FillingDelegates) { fillingDelegate(reader, entityObject, layer.LayerOffset + (notfirst ? 1 : 2)); notfirst = true; } successRead = true; if (layer.NextLayer != null) { //todo: nav-filling delegates - separate var nextPart = (SubTypePart) layer.NextLayer.TypePart; var property = entityObject.GetType().GetProperty(nextPart.CollectingProperty.Name); if (property.PropertyType.IsCollection()) { var itemType = property.PropertyType.GetCollectionType(); var collection = (IList) Activator.CreateInstance(typeof (List<>).MakeGenericType(itemType)); while (successRead && ((IComparable)reader.GetValue(layer.LayerOffset)).CompareTo(val) == 0) { var propObj = LoadObjectTree(layer.NextLayer, reader, out successRead); collection.Add(propObj); } if (property.PropertyType.IsArray) { var array = Array.CreateInstance(itemType, collection.Count); collection.CopyTo(array, 0); property.SetValue(entityObject, array); } else { property.SetValue(entityObject, collection); } } else { while (successRead && ((IComparable)reader.GetValue(layer.LayerOffset)).CompareTo(val) == 0) { var propObj = LoadObjectTree(layer.NextLayer, reader, out successRead); property.SetValue(entityObject, propObj); } } } else if (layer.Expansions.Count > 0) { var exp = layer.Expansions.First(); var property = entityObject.GetType().GetProperty(exp.CollectingProperty.Name); var itemType = property.PropertyType.GetCollectionType(); var primitive = (PrimitiveListTable)exp.Table; var collection = (IList)Activator.CreateInstance(typeof(List<>).MakeGenericType(itemType)); if (primitive.MaintainOrder) { var dictionary = new SortedDictionary<long, object>(); var offset = layer.LayerEnds; while (successRead && ((IComparable) reader.GetValue(layer.LayerOffset)).CompareTo(val) == 0) { var k = reader.GetInt64(offset + 2); var v = reader.GetValue(offset + 1); dictionary[k] = v; successRead = reader.Read(); } //todo: optimize foreach (var item in dictionary) { collection.Add(item.Value); } } else { var offset = layer.LayerEnds; while (successRead && ((IComparable)reader.GetValue(layer.LayerOffset)).CompareTo(val) == 0) { var v = reader.GetValue(offset + 1); collection.Add(v); successRead = reader.Read(); } } if (property.PropertyType.IsArray) { var array = Array.CreateInstance(itemType, collection.Count); collection.CopyTo(array, 0); property.SetValue(entityObject, array); } else { property.SetValue(entityObject, collection); } } else { successRead = reader.Read(); } return entityObject; }
private void button1_Click(object sender, EventArgs e) { if (_cmbLayer1.SelectedIndex >= 0 && _cmbLayer2.SelectedIndex >= 0 && _cmbOperation.SelectedIndex >= 0) { //obrada forme if (_cmbOperation.SelectedIndex == 0) //intersect { SharpMap.Data.FeatureDataSet ds = new SharpMap.Data.FeatureDataSet(); SharpMap.Layers.VectorLayer layer1 = (SharpMap.Layers.VectorLayer)_map.GetLayerByName(_cmbLayer1.SelectedItem.ToString()); SharpMap.Layers.VectorLayer layer2 = (SharpMap.Layers.VectorLayer)_map.GetLayerByName(_cmbLayer2.SelectedItem.ToString()); SharpMap.Data.Providers.NtsProvider nts = new SharpMap.Data.Providers.NtsProvider(layer1.DataSource); SharpMap.Data.Providers.NtsProvider nts2 = new SharpMap.Data.Providers.NtsProvider(layer2.DataSource); SharpMap.Geometries.GeometryCollection coll = new SharpMap.Geometries.GeometryCollection(); ds.Tables.Clear(); SharpMap.Data.FeatureDataSet set = new SharpMap.Data.FeatureDataSet(); nts.GetFeaturesInView(nts.GetExtents(), set); SharpMap.Data.FeatureDataSet res = new SharpMap.Data.FeatureDataSet(); res.Tables.Add(set.Tables[0].Clone()); res.Tables[0].Rows.Clear(); ds.Tables.Clear(); foreach (SharpMap.Data.FeatureDataRow row in set.Tables[0].Rows) { nts2.ExecuteIntersectionQuery(row.Geometry, ds); if (ds.Tables[0].Rows.Count > 0) { SharpMap.Data.FeatureDataRow red = res.Tables[0].NewRow(); red.Geometry = row.Geometry; red.ItemArray = row.ItemArray; res.Tables[0].AddRow(red); } ds.Tables.Clear(); } LayerInfo l = new LayerInfo(res.Tables[0]); l.Show(); SharpMap.Data.Providers.GeometryFeatureProvider prov = new SharpMap.Data.Providers.GeometryFeatureProvider(res.Tables[0]); SharpMap.Layers.VectorLayer lay = new SharpMap.Layers.VectorLayer("selected layer", prov); lay.Style.Fill = Brushes.Yellow; SharpMap.Layers.ILayer layerToRemove = _map.GetLayerByName("selected layer"); if (layerToRemove != null) { _map.Layers.Remove(layerToRemove); } _map.Layers.Add(lay); this._parent.RefreshMap(); } else if (_cmbOperation.SelectedIndex == 1)//within { SharpMap.Data.FeatureDataSet ds = new SharpMap.Data.FeatureDataSet(); SharpMap.Layers.VectorLayer layer1 = (SharpMap.Layers.VectorLayer)_map.GetLayerByName(_cmbLayer1.SelectedItem.ToString()); SharpMap.Layers.VectorLayer layer2 = (SharpMap.Layers.VectorLayer)_map.GetLayerByName(_cmbLayer2.SelectedItem.ToString()); SharpMap.Data.Providers.NtsProvider nts = new SharpMap.Data.Providers.NtsProvider(layer1.DataSource); SharpMap.Data.Providers.NtsProvider nts2 = new SharpMap.Data.Providers.NtsProvider(layer2.DataSource, CreateBuffers); SharpMap.Geometries.GeometryCollection coll = new SharpMap.Geometries.GeometryCollection(); ds.Tables.Clear(); SharpMap.Data.FeatureDataSet set = new SharpMap.Data.FeatureDataSet(); nts.GetFeaturesInView(nts.GetExtents(), set); SharpMap.Data.FeatureDataSet res = new SharpMap.Data.FeatureDataSet(); res.Tables.Add(set.Tables[0].Clone()); res.Tables[0].Rows.Clear(); ds.Tables.Clear(); foreach (SharpMap.Data.FeatureDataRow row in set.Tables[0].Rows) { nts2.ExecuteIntersectionQuery(row.Geometry, ds); if (ds.Tables[0].Rows.Count > 0) { SharpMap.Data.FeatureDataRow red = res.Tables[0].NewRow(); red.Geometry = row.Geometry; red.ItemArray = row.ItemArray; res.Tables[0].AddRow(red); } ds.Tables.Clear(); } LayerInfo l = new LayerInfo(res.Tables[0]); l.Show(); SharpMap.Data.Providers.GeometryFeatureProvider prov = new SharpMap.Data.Providers.GeometryFeatureProvider(res.Tables[0]); SharpMap.Layers.VectorLayer lay = new SharpMap.Layers.VectorLayer("selected layer", prov); lay.Style.Fill = Brushes.Yellow; SharpMap.Layers.ILayer layerToRemove = _map.GetLayerByName("selected layer"); if (layerToRemove != null) { _map.Layers.Remove(layerToRemove); } _map.Layers.Add(lay); this._parent.RefreshMap(); } else//van { SharpMap.Data.FeatureDataSet ds = new SharpMap.Data.FeatureDataSet(); SharpMap.Layers.VectorLayer layer1 = (SharpMap.Layers.VectorLayer)_map.GetLayerByName(_cmbLayer1.SelectedItem.ToString()); SharpMap.Layers.VectorLayer layer2 = (SharpMap.Layers.VectorLayer)_map.GetLayerByName(_cmbLayer2.SelectedItem.ToString()); SharpMap.Data.Providers.NtsProvider nts = new SharpMap.Data.Providers.NtsProvider(layer1.DataSource); SharpMap.Data.Providers.NtsProvider nts2 = new SharpMap.Data.Providers.NtsProvider(layer2.DataSource, CreateBuffers); SharpMap.Geometries.GeometryCollection coll = new SharpMap.Geometries.GeometryCollection(); ds.Tables.Clear(); SharpMap.Data.FeatureDataSet set = new SharpMap.Data.FeatureDataSet(); nts.GetFeaturesInView(nts.GetExtents(),set); SharpMap.Data.FeatureDataSet res = new SharpMap.Data.FeatureDataSet(); res.Tables.Add(set.Tables[0].Clone()); res.Tables[0].Rows.Clear(); ds.Tables.Clear(); foreach (SharpMap.Data.FeatureDataRow row in set.Tables[0].Rows) { nts2.ExecuteIntersectionQuery(row.Geometry, ds); if (ds.Tables[0].Rows.Count <= 0) { SharpMap.Data.FeatureDataRow red = res.Tables[0].NewRow(); red.Geometry = row.Geometry; red.ItemArray = row.ItemArray; res.Tables[0].AddRow(red); } ds.Tables.Clear(); } LayerInfo l = new LayerInfo(res.Tables[0]); l.Show(); SharpMap.Data.Providers.GeometryFeatureProvider prov = new SharpMap.Data.Providers.GeometryFeatureProvider(res.Tables[0]); SharpMap.Layers.VectorLayer lay = new SharpMap.Layers.VectorLayer("selected layer", prov); lay.Style.Fill = Brushes.Yellow; SharpMap.Layers.ILayer layerToRemove = _map.GetLayerByName("selected layer"); if (layerToRemove != null) { _map.Layers.Remove(layerToRemove); } _map.Layers.Add(lay); this._parent.RefreshMap(); } } }