Ejemplo n.º 1
0
        public List<Feature> startSelectSite()
        {
            IGeometry allGeom = baseFeature.Shape;

            Dictionary<string, double> dict = GisUtil.GetExternalRectDimension(allGeom);
            GisUtil.CreateEnvelopFishnet(fishnetWidth, fishnetHeight, getFullPath(targetFolder, fishnetName), dict);
            GisUtil.FeatureToPolygon(getFullPath(targetFolder, fishnetName), getFullPath(targetFolder, fishnetPolygonName));

            IFeatureClass featureClass = GisUtil.getFeatureClass(targetFolder, fishnetPolygonName); //获得网格类, 其中的网格已成面.
            for (int i = 0; i < featureClass.FeatureCount(null); i++)
            {
                Feature feature = new Feature();
                featureList.Add(feature);
            }
            for (int i = 0; i < conditionList.Count; i++)
            {
                Condition condition = conditionList[i];
                Label label = new Label();
                label.id = condition.labelID;
                label.select();
                string targetLyName = GisUtil.GetShpNameByMapLayerName(mapControl, label.mapLayerName) + ".shp";
                if (condition.type == C.CONFIG_TYPE_RESTRAINT)
                {
                    if (condition.category == C.CONFIG_CATEGORY_DISTANCE_NEGATIVE)
                    {
                        negativeDistanceRestraint(featureClass, targetLyName, condition.value, featureList);
                    }
                    else if (condition.category == C.CONFIG_CATEGORY_DISTANCE_POSITIVE)
                    {
                        positiveDistanceRestraint(featureClass, targetLyName, condition.value, featureList);
                    }
                    else if (condition.category == C.CONFIG_CATEGORY_INTERSECT_NEGATIVE)
                    {
                        negativeIntersectRestraint(featureClass, targetLyName, condition.value, featureList);
                    }
                    else if (condition.category == C.CONFIG_CATEGORY_INTERSECT_POSITIVE)
                    {
                        positiveIntersectRestraint(featureClass, targetLyName, condition.value, featureList);
                    }
                    else if (condition.category == C.CONFIG_CATEGORY_OVERLAP_NEGATIVE)
                    {
                        negativeOverlapRestraint(featureClass, targetLyName, condition.value, featureList);
                    }
                    else if (condition.category == C.CONFIG_CATEGORY_OVERLAP_POSITIVE)
                    {
                        positiveOverlapRestraint(featureClass, targetLyName, condition.value, featureList);
                    }
                }
                else if(condition.type == C.CONFIG_TYPE_STANDARD)
                {
                    if (condition.category == C.CONFIG_CATEGORY_DISTANCE_NEGATIVE)
                    {
                        negativeDistanceStandard(featureClass, targetLyName, condition.value / totalStandardValue, featureList);
                    }
                    else if (condition.category == C.CONFIG_CATEGORY_DISTANCE_POSITIVE)
                    {
                        positiveDistanceStandard(featureClass, targetLyName, condition.value / totalStandardValue, featureList);
                    }
                    else if (condition.category == C.CONFIG_CATEGORY_OVERLAP_NEGATIVE)
                    {
                        negativeOverlapStandard(featureClass, targetLyName, condition.value / totalStandardValue, featureList);
                    }
                    else if (condition.category == C.CONFIG_CATEGORY_OVERLAP_POSITIVE)
                    {
                        positiveOverlapStandard(featureClass, targetLyName, condition.value / totalStandardValue, featureList);
                    }
                }
            }

            DrawSelectResult(featureClass);
            return featureList;
        }
Ejemplo n.º 2
0
 public List<Feature> SelectSiteSelectResultByPrID(int prID)
 {
     List<Feature> feaInfoList = new List<Feature>();
     string comm = "select * from SiteResult where prID=" + prID.ToString();
     SqlConnection conn = openConn();
     SqlCommand com = new SqlCommand(comm, conn);
     SqlDataReader reader = com.ExecuteReader();
     if (reader.HasRows)
     {
         while (reader.Read())
         {
             Feature fea = new Feature();
             feaInfoList.Add(fea);
         }
         closeConnection(conn);
         return feaInfoList;
     }
     else
     {
         closeConnection(conn);
         return null;
     }
 }
Ejemplo n.º 3
0
        public List<Feature> startSelectSite()
        {
            convertRasterToPolygon(mapControl, targetFolder);
            EraseDrawnGeometryList(mapControl);
            IGeometry allGeom = baseFeature.Shape;
            rootGeometry = baseFeature.Shape;

            Dictionary<string, double> dict = GisUtil.GetExternalRectDimension(allGeom);
            GisUtil.CreateEnvelopFishnet(fishnetWidth, fishnetHeight, getFullPath(targetFolder, fishnetName), dict);
            GisUtil.FeatureToPolygon(getFullPath(targetFolder, fishnetName), getFullPath(targetFolder, fishnetPolygonName));

            IFeatureClass featureClass = GisUtil.getFeatureClass(targetFolder, fishnetPolygonName); //获得网格类, 其中的网格已成面.
            ISpatialFilter filter = new SpatialFilterClass();
            filter.Geometry = rootGeometry;
            filter.GeometryField = "SHAPE";
            filter.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects;
            IFeatureCursor cursor = featureClass.Search(filter, false);
            IFeature feature;
            while ((feature = cursor.NextFeature()) != null)
            {
                Feature fea = new Feature();
                fea.inUse = 1;
                fea.score = -1;
                fea.relativeFeature = feature;
                featureList.Add(fea);
            }
            
            for (int i = 0; i < conditionList.Count; i++)
            {
                Condition condition = conditionList[i];
                Label label = new Label();
                label.id = condition.labelID;
                label.select();
                string targetLyName = System.IO.Path.GetFileName(label.mapLayerPath);
                if (condition.type == C.CONFIG_TYPE_RESTRAINT)
                {
                    if (condition.category == C.CONFIG_CATEGORY_RESTRAINT_DISTANCE_BIGGER)
                    {
                        biggerDistanceRestraint(targetLyName, condition.value, featureList);
                    }
                    else if (condition.category == C.CONFIG_CATEGORY_RESTRAINT_DISTANCE_BIGGEREQUAL)
                    {
                        biggerEqualDistanceRestraint(targetLyName, condition.value, featureList);
                    }
                    else if (condition.category == C.CONFIG_CATEGORY_RESTRAINT_DISTANCE_SMALLER)
                    {
                        smallerDistanceRestraint(targetLyName, condition.value, featureList);
                    }
                    else if (condition.category == C.CONFIG_CATEGORY_RESTRAINT_DISTANCE_SMALLEREQUAL)
                    {
                        smallerEqualDistanceRestraint(targetLyName, condition.value, featureList);
                    }
                    else if (condition.category == C.CONFIG_CATEGORY_RESTRAINT_INTERSECT_BIGGER)
                    {
                        biggerIntersectRestraint(targetLyName, condition.value, featureList);
                    }
                    else if (condition.category == C.CONFIG_CATEGORY_RESTRAINT_INTERSECT_BIGGEREQUAL)
                    {
                        biggerEqualIntersectRestraint(targetLyName, condition.value, featureList);
                    }
                    else if (condition.category == C.CONFIG_CATEGORY_RESTRAINT_INTERSECT_SMALLER)
                    {
                        smallerIntersectRestraint(targetLyName, condition.value, featureList);
                    }
                    else if (condition.category == C.CONFIG_CATEGORY_RESTRAINT_INTERSECT_SMALLEREQUAL)
                    {
                        smallerEqualIntersectRestraint(targetLyName, condition.value, featureList);                            
                    }
                    else if (condition.category == C.CONFIG_CATEGORY_RESTRAINT_OVERLAP_BIGGER)
                    {
                        biggerOverlapRestraint(targetLyName, condition.value, featureList);                                                    
                    }
                    else if (condition.category == C.CONFIG_CATEGORY_RESTRAINT_OVERLAP_BIGGEREQUAL)
                    {
                        biggerEqualOverlapRestraint(targetLyName, condition.value, featureList);                                                                            
                    }
                    else if (condition.category == C.CONFIG_CATEGORY_RESTRAINT_OVERLAP_SMALLER)
                    {
                        smallerOverlapRestraint(targetLyName, condition.value, featureList);
                    }
                    else if (condition.category == C.CONFIG_CATEGORY_RESTRAINT_OVERLAP_SMALLEREQUAL)
                    {
                        smallerEqualOverlapRestraint(targetLyName, condition.value, featureList);                                                                           
                    }
                }
                else if(condition.type == C.CONFIG_TYPE_STANDARD)
                {
                    if (condition.category == C.CONFIG_CATEGORY_STANDARD_DISTANCE_NEGATIVE)
                    {
                        negativeDistanceStandard(targetLyName, condition.value / totalStandardValue, featureList);
                    }
                    else if (condition.category == C.CONFIG_CATEGORY_STANDARD_DISTANCE_POSITIVE)
                    {
                        positiveDistanceStandard(targetLyName, condition.value / totalStandardValue, featureList);
                    }
                    else if (condition.category == C.CONFIG_CATEGORY_STANDARD_OVERLAP_NEGATIVE)
                    {
                        negativeOverlapStandard(targetLyName, condition.value / totalStandardValue, featureList);
                    }
                    else if (condition.category == C.CONFIG_CATEGORY_STANDARD_OVERLAP_POSITIVE)
                    {
                        positiveOverlapStandard(targetLyName, condition.value / totalStandardValue, featureList);
                    }
                }
            }

            GisUtil.CreateShapefile(mapFolder, "评价结果.shp", mapControl.SpatialReference);
            IFeatureClass resultFeatureClass = GisUtil.getFeatureClass(mapFolder, "评价结果.shp");
            GisUtil.addFeatureLayerField(resultFeatureClass, "rslt", esriFieldType.esriFieldTypeDouble, 10);
            for (int i = 0; i < featureList.Count; i++)
            {
                GisUtil.AddGeometryToFeatureClass(featureList[i].relativeFeature.Shape, resultFeatureClass);
                GisUtil.setValueToFeatureClass(resultFeatureClass, resultFeatureClass.FeatureCount(null) - 1, "rslt", featureList[i].score.ToString());
            }
            IFeatureLayer resultFeatureLayer = new FeatureLayerClass();
            resultFeatureLayer.FeatureClass = resultFeatureClass;
            mapControl.AddLayer(resultFeatureLayer);
            return featureList;
        }