コード例 #1
0
 private void OnOgrGeometryChanged()
 {
     _ignoreGeoChanged   = true;
     _ignoreCoordChanged = true;
     Geometries.Clear();
     Coordinates.Clear();
     if (OgrGeometry != null)
     {
         var geometryCount = OgrGeometry.GetGeometryCount();
         if (geometryCount == 0)
         {
             var pointCount = OgrGeometry.GetPointCount();
             var dimension  = OgrGeometry.GetCoordinateDimension();
             for (int i = 0; i < pointCount; i++)
             {
                 double[] argout = new double[dimension];
                 OgrGeometry.GetPoint(i, argout);
                 Coordinate coordinate = new Coordinate(argout);
                 Coordinates.Add(coordinate);
             }
         }
         else
         {
             for (int i = 0; i < geometryCount; i++)
             {
                 var      ogrGeometry = OgrGeometry.GetGeometryRef(i);
                 Geometry geometry    = new Geometry(ogrGeometry);
                 Geometries.Add(geometry);
             }
         }
     }
     _ignoreGeoChanged   = false;
     _ignoreCoordChanged = false;
 }
コード例 #2
0
 public void SetXYZ(double x, double y, double z)
 {
     Coordinates.Clear();
     Coordinates.Add(x);
     Coordinates.Add(y);
     Coordinates.Add(z);
 }
コード例 #3
0
        /// <summary>
        /// Clears the active elements
        /// </summary>
        internal virtual void Clear()
        {
            Coordinates.Clear();
            LastCoordinate       = null;
            LastMouseCoordinate  = null;
            this.FeatureGeometry = new List <FrameworkElement>();

            RaiseStatusSegmentLengthChanged("");
            RaiseTotalLengthChanged("");
            RaiseAreaChanged("");
        }
コード例 #4
0
        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox1.Text == "" || textBox2.Text == "")
                {
                    MessageBox.Show("No image Height or Width given", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (Coordinates.Count != 2)
                {
                    MessageBox.Show("Wrong number of Coordinates!\n" +
                                    "Reselect 2 Coordinates and try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Coordinates.Clear();
                }
                else
                {
                    double realImageHeight = Convert.ToDouble(textBox1.Text);
                    double realImageWidth  = Convert.ToDouble(textBox2.Text);
                    ScaleHW = new Tuple <double, double>(realImageHeight / PictureBox.Height, realImageWidth / PictureBox.Width);
                    double mHeight  = Math.Abs(Coordinates[0].Y - Coordinates[1].Y) * ScaleHW.Item1;
                    double mWidth   = Math.Abs(Coordinates[0].X - Coordinates[1].X) * ScaleHW.Item2;
                    double distance = Math.Sqrt(mWidth * mWidth + mHeight * mHeight);
                    MessageBox.Show(string.Format("The measured distance is: {0} cm.", distance));

                    if (this.FlowerDimensions["sepal"].Count != 2)
                    {
                        this.FlowerDimensions["sepal"].Add(distance);
                    }
                    else
                    {
                        this.FlowerDimensions["petal"].Add(distance);
                    }

                    Coordinates.Clear();
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Invalid format for image Height or Width", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
コード例 #5
0
ファイル: MapViewModel.cs プロジェクト: Maxusbr/ClientApps
        private void SearchGeo(object obj)
        {
            var res = new List <Location>();

            if (!string.IsNullOrEmpty(this.House) && !string.IsNullOrEmpty(this.Street) && !string.IsNullOrEmpty(this.City))
            {
                res = GeoAdress.Instance.GetCoordinat(this.House, this.Street, this.City);
            }
            if (res == null)
            {
                return;
            }
            Coordinates.Clear();
            foreach (var el in res)
            {
                Coordinates.Add(el);
            }
            if (Coordinates.Count > 0)
            {
                Coordinate = Coordinates[0];
            }
        }
コード例 #6
0
        /// <summary>
        /// Closes the measurer
        /// </summary>
        internal override void CloseMeasurer()
        {
            if (Coordinates.Count == 0)
            {
                // No Coordinates; so not drawing; clear everything
                Clear();
            }
            else if (Coordinates.Count <= 2)
            {
                if (_elements.Count > 1)
                {
                    Coordinates.Clear();
                    LastCoordinate      = null;
                    LastMouseCoordinate = null;
                    _elements.RemoveAt(_elements.Count - 1);

                    var element = new FreeElement();
                    element.OnCSUnitsPerPixelChanged(this.CSUnitsPerPixel);
                    _elements.Add(element);

                    CreateFeatureGeometry();
                }
                else
                {
                    Clear();
                }
            }
            else
            {
                ActiveCollection.Close();
                EndMeasuring();

                Coordinates.Clear();
                LastCoordinate      = null;
                LastMouseCoordinate = null;
            }
        }
コード例 #7
0
        public Coordinates Filter(Coordinates inputPts)
        {
            _newPts.Clear();
            int i = 0;

            while (i < inputPts.Count)
            {
                AddPoint((Coordinate)inputPts[i]);
                int loopSize = CheckForLoop(inputPts, i);
                // skip loop if one was found
                i++;
                if (loopSize > 0)
                {
                    //Assert.isTrue(inputPts[i - 1].equals(inputPts[i - 1 + loopSize]), "non-loop found in LoopFilter");
                    if (!(inputPts[i - 1].Equals(inputPts[i - 1 + loopSize])))
                    {
                        throw new InvalidOperationException("non-loop found in LoopFilter");
                    }
                    i += loopSize;
                }
            }
            //return (Coordinate[]) newPts.toArray(arrayTypeCoordinate);
            return(_newPts);
        }
コード例 #8
0
 public void SetXY(double x, double y)
 {
     Coordinates.Clear();
     Coordinates.Add(x);
     Coordinates.Add(y);
 }