public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
 {
     int labelID = (int)value;
     Label label = new Label();
     label.id = labelID;
     label.select();
     return label.content;
 }
Exemplo n.º 2
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;
        }
Exemplo 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;
        }
        public void init(int programID)
        {
            if (program == null)
                program = new Program();
            program.id = programID;
            program.select();

            if (project == null)
                project = new Project();
            project.id = program.projectID;
            project.select();

            ObservableCollection<Label> labelList;
            ObservableCollection<Condition> tempList;
            conditionList = new ObservableCollection<Condition>();
            extraConditionList = new ObservableCollection<Condition>();
            tempList = program.getAllRelatedCondition();
            if (tempList.Count == 0)
            {
                //新建的方案, 没有条件. 把标签中使用的添加进去.
                labelList = project.getAllRelatedLabel();
                foreach (Label label in labelList)
                {
                    if (label.isChoosed)
                    {
                        Condition condition = new Condition();
                        condition.labelID = label.id;
                        condition.programID = program.id;
                        condition.saveWithoutCheck();
                        condition.id = Condition.GetLastConditionID();
                        conditionList.Add(condition);
                    }
                }
            }
            else
            {
                foreach (Condition condition in tempList)
                {
                    int labelID = condition.labelID;
                    Label label = new Label();
                    label.id = labelID;
                    label.select();
                    if (label.isChoosed)
                    {
                        conditionList.Add(condition);
                    }
                    else
                    {
                        labelList = project.getAllRelatedLabel();
                        foreach (Label l in labelList)
                        {
                            condition.labelList.Add(l);
                        }
                        extraConditionList.Add(condition);
                    }
                }
            }

            ConditionListBox.ItemsSource = conditionList;
            ExtraConditionListBox.ItemsSource = extraConditionList;
        }
Exemplo n.º 5
0
 public ObservableCollection<Label> getAllRelatedLabel()
 {
     if (!isValid())
         return null;
     ObservableCollection<Label> labelList = new ObservableCollection<Label>();
     string sqlCommand = String.Format("select lID from Label where pID = {0}", pID);
     Sql sql = new Sql();
     SqlDataReader reader = sql.selectAllLabelIDByPID(sqlCommand);
     while (reader.Read())
     {
         int lID = Int32.Parse(reader[0].ToString());
         Label label = new Label();
         label.id = lID;
         label.select();
         labelList.Add(label);
     }
     sql.closeConnection();
     return labelList;
 }