示例#1
0
 public Style(string name, StyleType type, RenderRule defaultRule)
 {
     this.name        = name;
     this.styletype   = type;
     rulelist         = new List <RenderRule>();
     this.defaultRule = defaultRule;
 }
示例#2
0
        public static Style createUniqueValueStyle(FeatureSource featuresource, string arrtributename)
        {
            //arrtributename = featuresource.schema.fields.Keys.First();//////????????????????????????????????????//
            Schema         schema = featuresource.schema;
            SymbolizerType sign   = SymbolizerType.POINT;

            switch (schema.geometryType)
            {
            case OSGeo.OGR.wkbGeometryType.wkbPoint:
                sign = SymbolizerType.POINT;
                break;

            case OSGeo.OGR.wkbGeometryType.wkbLineString:
                sign = SymbolizerType.LINE;
                break;

            case OSGeo.OGR.wkbGeometryType.wkbPolygon:
                sign = SymbolizerType.POLYGON;
                break;
            }
            //获取attributename 所对应的所有不同属性值
            HashSet <object> set = new HashSet <object>();
            List <GisSmartTools.Data.Feature> featurelist = featuresource.features.featureList;

            foreach (GisSmartTools.Data.Feature feature in featurelist)
            {
                set.Add(feature.GetArrtributeByName(arrtributename));
            }
            List <RenderRule> rulelist = new List <RenderRule>();

            foreach (object value in set)
            {
                RenderRule rule = RenderRule.createDefaultRule(sign);
                rule.filter = new Filter_Equals(arrtributename, value);
                rulelist.Add(rule);
            }
            Style style = new Style("uniqueValueStyle", StyleType.UNIQUESTYLE, RenderRule.createDefaultRule(sign));

            style.rulelist = rulelist;
            return(style);
        }
示例#3
0
        public static Style createSimpleStyle(FeatureSource featuresource)
        {
            RenderRule rule = null;

            switch (featuresource.schema.geometryType)
            {
            case OSGeo.OGR.wkbGeometryType.wkbPoint:
                rule = RenderRule.createDefaultRule(SymbolizerType.POINT);
                break;

            case OSGeo.OGR.wkbGeometryType.wkbLineString:
                rule = RenderRule.createDefaultRule(SymbolizerType.LINE);
                break;

            case OSGeo.OGR.wkbGeometryType.wkbPolygon:
                rule = RenderRule.createDefaultRule(SymbolizerType.POLYGON);
                break;
            }
            Style simplestyle = new Style("simplestyle", StyleType.SIMPLESTYLE, rule);

            return(simplestyle);
        }
示例#4
0
        public static Style createRankStyle(FeatureSource featuresource, string attributename, int num, Color startcolor, Color endcolor)
        {
            Schema         schema = featuresource.schema;
            SymbolizerType sign   = SymbolizerType.POINT;

            switch (schema.geometryType)
            {
            case OSGeo.OGR.wkbGeometryType.wkbPoint:
                sign = SymbolizerType.POINT;
                break;

            case OSGeo.OGR.wkbGeometryType.wkbLineString:
                sign = SymbolizerType.LINE;
                break;

            case OSGeo.OGR.wkbGeometryType.wkbPolygon:
                sign = SymbolizerType.POLYGON;
                break;
            }
            FieldDefn fielddefn = null;

            if (schema.fields.TryGetValue(attributename, out fielddefn) || attributename.Equals("FeatureID"))
            {
                FieldType type = FieldType.OFTString;
                if (!attributename.Equals("FeatureID"))
                {
                    type = fielddefn.GetFieldType();
                }
                if (type == FieldType.OFTInteger || type == FieldType.OFTReal || attributename.Equals("FeatureID"))
                {
                    double maxvalue = double.MinValue;
                    double minvalue = double.MaxValue;
                    foreach (GisSmartTools.Data.Feature feature in featuresource.features.featureList)
                    {
                        double value = 0;
                        if (type == FieldType.OFTInteger || attributename.Equals("FeatureID"))
                        {
                            value = (int)feature.GetArrtributeByName(attributename);
                        }
                        if (type == FieldType.OFTReal)
                        {
                            value = (double)feature.GetArrtributeByName(attributename);
                        }
                        if (value > maxvalue)
                        {
                            maxvalue = value;
                        }
                        if (value < minvalue)
                        {
                            minvalue = value;
                        }
                    }
                    if (num == 0)
                    {
                        return(null);
                    }
                    double x = (maxvalue - minvalue) / num;
                    //逐个创建对应的rule
                    Color[]           colorarray    = Utils.GetLinearColorList(startcolor, endcolor, num);
                    double            temp_minvalue = minvalue;
                    double            temp_maxvalue = minvalue + x;
                    List <RenderRule> rulelist      = new List <RenderRule>();
                    // Printer.printnode("min=" + minvalue + " max=" + maxvalue, "");

                    for (int i = 0; i < num; i++)
                    {
                        RenderRule           rule       = RenderRule.createDefaultRule(sign, colorarray[i]);
                        Filter_Larger        larger     = new Filter_Larger(attributename, temp_minvalue);
                        Filter_Less          less       = new Filter_Less(attributename, temp_maxvalue);
                        List <Filter.Filter> filterlist = new List <Filter.Filter>();
                        filterlist.Add(larger); filterlist.Add(less);
                        Filter_And andfilter = new Filter_And(filterlist);
                        rule.filter = andfilter;
                        rulelist.Add(rule);
                        // Printer.printnode("temp_" + i, "min=" + temp_minvalue + " max=" + temp_maxvalue);
                        temp_minvalue += x; temp_maxvalue += x;
                    }
                    Style rankstyle = new Style("RankStyle", StyleType.RANKSTYLE, RenderRule.createDefaultRule(sign, startcolor));
                    rankstyle.rulelist = rulelist;
                    Printer.printnode("rulist,count=", "" + rulelist.Count);
                    return(rankstyle);
                }
            }
            return(null);
        }
示例#5
0
 public void setDefalutRule(RenderRule defaultRule)
 {
     this.defaultRule = defaultRule;
 }
示例#6
0
 public bool addRule(RenderRule rule)
 {
     rulelist.Add(rule);
     return(true);
 }