public bool AddShape(SHPObject sObject) { if (sObject.env == null) { Shapes.Add(sObject); return(true); } if (SubNodes.Count > 0) { foreach (DualTreeNode subNode in SubNodes) { if (subNode.CheckObjectContained(sObject)) { return(subNode.AddShape(sObject)); } // wenn in keines der Subnudes passt -> in eigenes übernehmen (ohne Kontrolle auf überlauf) //Shapes.Add(sObject); //return true; } } //else { Shapes.Add(sObject); if (Shapes.Count > DualTreeNode.maxPerNode) { this.SplitTreeNode(); } return(true); } return(false); }
private bool SHPCheckObjectContained(SHPObject psObject, IEnvelope Bounds) { if (psObject.env.minx < Bounds.minx || psObject.env.maxx > Bounds.maxx) { return(false); } if (psObject.env.miny < Bounds.miny || psObject.env.maxy > Bounds.maxy) { return(false); } return(true); //if( nDimension == 2 ) // return true; /* * if( psObject->dfZMin < padfBoundsMin[2] || psObject->dfZMax < padfBoundsMax[2] ) || return false; || ||if( nDimension == 3 ) || return true; || ||if( psObject->dfMMin < padfBoundsMin[3] || psObject->dfMMax < padfBoundsMax[3] ) || return FALSE; */ //return false; }
public bool SHPTreeAddShapeId(SHPObject psObject) { if (psTree == null) { return(false); } return(SHPTreeNodeAddShapeId(psTree.psRoot, psObject, psTree.nMaxDepth, psTree.nDimension)); }
private bool CheckObjectContained(SHPObject psObject) { if (psObject.env.minx < Bounds.minx || psObject.env.maxx > Bounds.maxx) { return(false); } if (psObject.env.miny < Bounds.miny || psObject.env.maxy > Bounds.maxy) { return(false); } return(true); }
public bool AddShape(SHPObject shape) { _featureCount++; if ((_featureCount % 100) == 0 && ReportProgress != null) { if (_report == null) { _report = new ProgressReport(); } _report.Message = "Add Features..."; _report.featureMax = -1; _report.featurePos = _featureCount; ReportProgress(_report); } return(_root.AddShape(shape)); }
private bool SHPTreeNodeAddShapeId(SHPTreeNode psTreeNode, SHPObject psObject, int nMaxDepth, int nDimension) { int i; /* -------------------------------------------------------------------- */ /* If there are subnodes, then consider wiether this object */ /* will fit in them. */ /* -------------------------------------------------------------------- */ if (nMaxDepth > 1 && psTreeNode.nSubNodes > 0) { for (i = 0; i < psTreeNode.nSubNodes; i++) { if (SHPCheckObjectContained(psObject, ((SHPTreeNode)psTreeNode.apsSubNode[i]).Bounds)) { return(SHPTreeNodeAddShapeId((SHPTreeNode)psTreeNode.apsSubNode[i], psObject, nMaxDepth - 1, nDimension)); } } } else if (nMaxDepth > 1 && psTreeNode.nSubNodes == 0) { //double [] adfBoundsMinH1=new double[4], adfBoundsMaxH1=new double[4]; //double [] adfBoundsMinH2=new double[4], adfBoundsMaxH2=new double[4]; // double [] adfBoundsMin1=new double[4], adfBoundsMax1=new double[4]; // double [] adfBoundsMin2=new double[4], adfBoundsMax2=new double[4]; // double [] adfBoundsMin3=new double[4], adfBoundsMax3=new double[4]; // double [] adfBoundsMin4=new double[4], adfBoundsMax4=new double[4]; IEnvelope BoundsH1, BoundsH2, Bounds1, Bounds2, Bounds3, Bounds4; SHPTreeSplitBounds(psTreeNode.Bounds, out BoundsH1, out BoundsH2); SHPTreeSplitBounds(BoundsH1, out Bounds1, out Bounds2); SHPTreeSplitBounds(BoundsH2, out Bounds3, out Bounds4); bool b1 = false, b2 = false, b3 = false, b4 = false; if ((b1 = SHPCheckObjectContained(psObject, Bounds1)) || (b2 = SHPCheckObjectContained(psObject, Bounds2)) || (b3 = SHPCheckObjectContained(psObject, Bounds3)) || (b4 = SHPCheckObjectContained(psObject, Bounds4))) { //psTreeNode->nSubNodes = 4; //psTreeNode.apsSubNode.Clear(); psTreeNode.apsSubNode.Add(SHPTreeNodeCreate(Bounds1)); psTreeNode.apsSubNode.Add(SHPTreeNodeCreate(Bounds2)); psTreeNode.apsSubNode.Add(SHPTreeNodeCreate(Bounds3)); psTreeNode.apsSubNode.Add(SHPTreeNodeCreate(Bounds4)); /* recurse back on this node now that it has subnodes */ return(SHPTreeNodeAddShapeId(psTreeNode, psObject, nMaxDepth, nDimension)); } } /* -------------------------------------------------------------------- */ /* Otherwise, consider creating two subnodes if could fit into */ /* them, and adding to the appropriate subnode. */ /* -------------------------------------------------------------------- */ else if (nMaxDepth > 1 && psTreeNode.nSubNodes == 0) { //double [] adfBoundsMin1=new double[4], adfBoundsMax1=new double[4]; //double [] adfBoundsMin2=new double[4], adfBoundsMax2=new double[4]; IEnvelope Bounds1, Bounds2; SHPTreeSplitBounds(psTreeNode.Bounds, out Bounds1, out Bounds2); if (SHPCheckObjectContained(psObject, Bounds1)) { //psTreeNode.nSubNodes = 2; psTreeNode.apsSubNode.Clear(); psTreeNode.apsSubNode.Add(SHPTreeNodeCreate(Bounds1)); psTreeNode.apsSubNode.Add(SHPTreeNodeCreate(Bounds2)); return(SHPTreeNodeAddShapeId((SHPTreeNode)psTreeNode.apsSubNode[0], psObject, nMaxDepth - 1, nDimension)); } else if (SHPCheckObjectContained(psObject, Bounds2)) { //psTreeNode.nSubNodes = 2; psTreeNode.apsSubNode.Clear(); psTreeNode.apsSubNode.Add(SHPTreeNodeCreate(Bounds1)); psTreeNode.apsSubNode.Add(SHPTreeNodeCreate(Bounds2)); return(SHPTreeNodeAddShapeId((SHPTreeNode)psTreeNode.apsSubNode[1], psObject, nMaxDepth - 1, nDimension)); } } /* -------------------------------------------------------------------- */ /* If none of that worked, just add it to this nodes list. */ /* -------------------------------------------------------------------- */ psTreeNode.panShapeIds.Add(psObject.ID); return(true); }