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;
 }
 public static bool IsUncompleteLabelComboBoxTextRepeat(ObservableCollection<Label> uncompleteLabelList, Label targetLabel, string content)
 {
     bool result = false;
     foreach (Label label in uncompleteLabelList)
     {
         if (label.mapLayerName == targetLabel.mapLayerName)
             continue;
         if (label.content == content)
         {
             result = true;
             break;
         }
     }
     return result;
 }
예제 #3
0
 public static Label GetLabelByMapLayerName(string mapLayerName)
 {
     string sqlCommand = String.Format(@"select * from Label where lMapLayerName='{0}'", mapLayerName);
     Sql sql = new Sql();
     SqlDataReader reader = sql.selectLabelByMapLayerName(sqlCommand);
     Label label = new Label();
     label.initBySqlDataReader(reader);
     sql.closeConnection();
     return label;
 }
예제 #4
0
 public static Label GetDefaultLabel()
 {
     Label label = new Label();
     return label;
 }
예제 #5
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;
        }
 public static void HideUncompleteLabelComboBoxItem(ObservableCollection<Label> uncompleteLabelList, Label targetLabel, string content)
 {
     foreach (Label label in uncompleteLabelList)
     {
         if (label.mapLayerName == targetLabel.mapLayerName)
             continue;
         label.uncomleteLabelContentManager.hideItem(content);
     }
 }
예제 #7
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;
        }
예제 #8
0
파일: Project.cs 프로젝트: Leooonard/CGXM
 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;
 }