private Dictionary <int, List <LabelLocation> > ReadAnnoLocations(string sqlanno, IDbConnection dbConn)
 {
     using (IDbCommand cmd = dbConn.CreateCommand())
     {
         cmd.CommandText = sqlanno;
         using (IDataReader dr = cmd.ExecuteReader())
         {
             int   oid   = -1;
             float angle = 0;
             Dictionary <int, List <LabelLocation> > retLocs = new Dictionary <int, List <LabelLocation> >();
             while (dr.Read())
             {
                 oid   = _adapter.DrToInt32(dr, 0);
                 angle = _adapter.DrToFloat(dr, 1);
                 Shape         shape = _adapter.DrToShape(dr, 2);
                 LabelLocation loc   = new LabelLocation(shape as ShapePoint, (int)angle);
                 //
                 if (retLocs.ContainsKey(oid))
                 {
                     retLocs[oid].Add(loc);
                 }
                 else
                 {
                     retLocs.Add(oid, new List <LabelLocation>(new LabelLocation[] { loc }));
                 }
             }
             return(retLocs);
         }
     }
 }
예제 #2
0
        private LabelLocation[] GetLabelLocation(string[] fields, string xfield, string yfield, string angleField, List <string[]> locArgs)
        {
            int ix     = Array.IndexOf(fields, xfield.ToUpper());
            int iy     = Array.IndexOf(fields, yfield.ToUpper());
            int iangle = Array.IndexOf(fields, angleField.ToUpper());

            if (ix == -1 || iy == -1 || iangle == -1)
            {
                return(null);
            }
            List <LabelLocation> locs = new List <LabelLocation>();

            foreach (string[] vs in locArgs)
            {
                double x     = 0;
                double y     = 0;
                float  angle = 0;
                if (!double.TryParse(vs[ix], out x))
                {
                    continue;
                }
                if (!double.TryParse(vs[iy], out y))
                {
                    continue;
                }
                if (vs[iangle].Trim() == string.Empty)
                {
                    vs[iangle] = "0";
                }
                if (!float.TryParse(vs[iangle], out angle))
                {
                    continue;
                }
                if (angle < 0)
                {
                    angle = Math.Abs(angle);
                }
                else
                {
                    angle = 360 - angle;
                }
                LabelLocation l = new LabelLocation(new ShapePoint(x, y), (int)angle);
                locs.Add(l);
            }
            return(locs.Count > 0 ? locs.ToArray() : null);
        }
예제 #3
0
     public override void UpdateLocations()
     {
         if (_geometry == null)
         {
             return;
         }
         if (_locations == null || _locations.Length == 0)
         {
             _locations = new LabelLocation[1] {
                 new LabelLocation()
             }
         }
         ;
         _locations[0].Angle    = 0;
         _locations[0].Location = _geometry.Centroid;
     }
 }
예제 #4
0
 public object Clone()
 {
     string[] flds = new string[_fieldNames.Length];
     for (int i = 0; i < _fieldNames.Length; i++)
     {
         flds[i] = _fieldNames[i];
     }
     string[] fldValuess = new string[_fieldValues.Length];
     for (int i = 0; i < _fieldValues.Length; i++)
     {
         fldValuess[i] = _fieldValues[i];
     }
     //Shape geo = _geometry.Clone();
     LabelLocation[] anns = null;
     if (_annotations != null)
     {
         anns = new LabelLocation[_annotations.Length];
         for (int i = 0; i < _annotations.Length; i++)
         {
             anns[i] = _annotations[i].Clone() as LabelLocation;
         }
     }
     return(new Feature(maxOID--, null, flds, fldValuess, anns));
 }