Ejemplo n.º 1
0
        public void GeoPolygon_Serialize()
        {
            GeoPolygon poly;

            poly = new GeoPolygon(
                new GeoCoordinate[] {
                new GeoCoordinate(10, 20)
            });

            poly = (GeoPolygon)GeoRegion.Parse(poly.ToString());
            Assert.AreEqual(1, poly.Vertices.Count);
            Assert.IsTrue(new GeoCoordinate(10, 20) == poly.Vertices[0]);

            poly = new GeoPolygon(
                new GeoCoordinate[] {
                new GeoCoordinate(10, 20),
                new GeoCoordinate(0, 20),
                new GeoCoordinate(0, 0)
            });

            poly = (GeoPolygon)GeoRegion.Parse(poly.ToString());
            Assert.AreEqual(3, poly.Vertices.Count);
            Assert.IsTrue(new GeoCoordinate(10, 20) == poly.Vertices[0]);
            Assert.IsTrue(new GeoCoordinate(0, 20) == poly.Vertices[1]);
            Assert.IsTrue(new GeoCoordinate(0, 0) == poly.Vertices[2]);
        }
Ejemplo n.º 2
0
        public async Task <List <GeoRegion> > GetGeoRegionsAsync(ContentURI uri)
        {
            Helpers.SqlIOAsync sqlIO = new Helpers.SqlIOAsync(uri);
            SqlDataReader      geoRegions
                = await sqlIO.RunProcAsync("0GetGeoRegions");

            List <GeoRegion> colGeoRegions = new List <GeoRegion>();

            if (geoRegions != null)
            {
                using (geoRegions)
                {
                    //build a related service list to return to the client
                    while (await geoRegions.ReadAsync())
                    {
                        GeoRegion newGeoRegion = new GeoRegion();
                        newGeoRegion.PKId          = geoRegions.GetInt32(0);
                        newGeoRegion.GeoRegionNum  = geoRegions.GetString(1);
                        newGeoRegion.GeoRegionName = geoRegions.GetString(2);
                        newGeoRegion.GeoRegionDesc = geoRegions.GetString(3);
                        colGeoRegions.Add(newGeoRegion);
                    }
                }
            }
            sqlIO.Dispose();
            return(colGeoRegions);
        }
Ejemplo n.º 3
0
        //
        public static GeoRegion GetRegionByQHBM(string strQHBM)
        {
            GeoRegion geoR = null;

            if (strQHBM.Length > 0)
            {
                try
                {
                    if (m_ChinaXZQH != null)
                    {
                        string strFilter = string.Format("code ='{0}'", strQHBM);
                        {
                            Recordset recdst = m_ChinaXZQH.Query(strQHBM, CursorType.Static);
                            if (recdst.RecordCount == 0)
                            {
                                strQHBM = string.Format("{0}00", strQHBM.Substring(0, 4));
                                recdst  = m_ChinaXZQH.Query(strQHBM, CursorType.Static);
                            }
                            geoR = recdst.GetGeometry() as GeoRegion;
                        }
                    }
                }

                catch { }
            }
            return(geoR);
        }
Ejemplo n.º 4
0
        public void GeoCircle_Serialize()
        {
            var circle1 = new GeoCircle(GeoCoordinate.Origin, 10, GeoHelper.EarthRadiusMiles);
            var circle2 = (GeoCircle)GeoRegion.Parse(circle1.ToString());

            Assert.AreEqual(circle1, circle2);
        }
 public override void writeTo(GeoWriter writer, bool l2j)
 {
     GeoCell[] layers;
     GeoRegion.putType(writer, l2j, getType());
     for (int x = 0, y, z; x < GeoEngine.GEO_BLOCK_SHIFT; x++)
     {
         for (y = 0; y < GeoEngine.GEO_BLOCK_SHIFT; y++)
         {
             layers = _cells3D[x, y];
             if (l2j)
             {
                 writer.put((byte)layers.Length);
             }
             else
             {
                 writer.putShort((short)layers.Length);
             }
             //
             for (z = layers.Length; z-- > 0;)
             {
                 writer.putShort(layers[z].getHeightAndNSWE());
             }
         }
     }
 }
 public override bool dataEquals(GeoReader reader)
 {
     if (getType() != GeoRegion.getType(reader, true))
     {
         return(false);
     }
     //
     GeoCell[] cells1D;
     for (int cellX = 0, cellY, layer; cellX < GeoEngine.GEO_BLOCK_SHIFT; cellX++)
     {
         for (cellY = 0; cellY < GeoEngine.GEO_BLOCK_SHIFT; cellY++)
         {
             cells1D = _cells3D[cellX, cellY];
             //
             if (cells1D.Length != reader.get())
             {
                 return(false);
             }
             //
             for (layer = cells1D.Length; layer-- > 0;)
             {
                 if (cells1D[layer].getHeightAndNSWE() != reader.getShort())
                 {
                     return(false);
                 }
             }
         }
     }
     return(true);
 }
Ejemplo n.º 7
0
        //---------------------------------------------------------------------
        // Static members

        internal static GeoQuery FromMessage(GeoQueryMsg queryMsg)
        {
            GeoQuery query = new GeoQuery();
            string   value;

            query.Options       = GeoQueryOptions.Load(queryMsg);
            query.EntityFilters = queryMsg._GetArray("EntityFilter");
            query.GroupFilters  = queryMsg._GetArray("QueryFilter");

            value = queryMsg._Get("Region", (string)null);
            if (!string.IsNullOrWhiteSpace(value))
            {
                query.Region = GeoRegion.Parse(value);
            }

            if (!string.IsNullOrWhiteSpace(queryMsg["MinTimeUtc"]))
            {
                query.MinTimeUtc = queryMsg._Get("MinTimeUtc", DateTime.MinValue);
            }

            if (!string.IsNullOrWhiteSpace(queryMsg["MaxTimeUtc"]))
            {
                query.MaxTimeUtc = queryMsg._Get("MaxTimeUtc", DateTime.MaxValue);
            }

            return(query);
        }
Ejemplo n.º 8
0
        //private void UpdateImageryCenterLocation(Point mousePosition, bool forceUpdate = false)
        //{
        //    if (this.TileImageryInteractionMode == TileImageryInteractionMode.MouseMove || forceUpdate ||
        //       (this.TileImageryInteractionMode == TileImageryInteractionMode.MouseRightClick && _isMapMouseRightClick) ||
        //       (this.TileImageryInteractionMode == TileImageryInteractionMode.MouseLeftClick && _isMapMouseLeftClick))
        //    {
        //        var geoLocation = this.GeographicMap.GetGeoLocation(mousePosition);
        //        if(!geoLocation.IsWithinSphericalMercatorWorld()) return;

        //        //if (!this.TileImageryCenterLocation.IsSameLocation(geoLocation))
        //        //{
        //        //    this.TileImageryCenterLocation.Longitude = geoLocation.Longitude;
        //        //    this.TileImageryCenterLocation.Latitude = geoLocation.Latitude;
        //        //}
        //    }
        //}
        private void UpdateImageryView(GeoRegion geoRegion, bool forceUpdate = false)
        {
            var mousePosition = this.GeographicMap.GetMapPosition(geoRegion.Center);

            //System.Diagnostics.Debug.WriteLine("Updating TileImageryRegion " + this.TileImageryRegion.CenterLongitude);
            UpdateImageryView(mousePosition, forceUpdate);
        }
Ejemplo n.º 9
0
        public void GeoRectangle_Serialize()
        {
            var r1 = new GeoRectangle(new GeoCoordinate(30, 20), new GeoCoordinate(-30, 5));
            var r2 = (GeoRectangle)GeoRegion.Parse(r1.ToString());

            Assert.AreEqual(r1, r2);
        }
Ejemplo n.º 10
0
        //---------------------------------------------------------------------
        // Utilities

        /// <summary>
        /// Returns the collection of blocks within a level's block array that potentially
        /// intersect a region.
        /// </summary>
        /// <param name="region">The <see cref="GeoRegion" /> being tested.</param>
        /// <param name="blockArray">The block array.</param>
        /// <returns>The list of potentially interscecing blocks.</returns>
        /// <remarks>
        /// <note>
        /// This method performs simply returns the set of blocks that intersect the bounding
        /// rectangle around the region rather than trying to compute this based on the detailed
        /// region shape: circle, polygon,...
        /// </note>
        /// </remarks>
        public static List <MercatorBlock> GetIntersectingBlocks(GeoRegion region, MercatorBlock[,] blockArray)
        {
            var blocks = new List <MercatorBlock>();
            var rBounds = region.Bounds;
            int cRows = blockArray.Rank + 1;
            int cColumns = blockArray.Length / cRows;
            int topRow, leftColumn;
            int bottomRow, rightColumn;

            if (cColumns == TopLevelColumnCount && cRows == TopLevelRowCount)
            {
                // Special case the top-level block array because we know that the region has to
                // intersect somewhere on the planet.

                topRow      = (int)((90.0 - rBounds.Northeast.Latitude) / 10.0);
                leftColumn  = (int)((180.0 + rBounds.Southwest.Longitude) / 10.0);
                bottomRow   = (int)((90.0 - rBounds.Southwest.Latitude) / 10.0);
                rightColumn = (int)((180.0 + rBounds.Northeast.Longitude) / 10.0);
            }
            else
            {
                var neBounds   = blockArray[0, 0].Bounds;
                var swBounds   = blockArray[cColumns - 1, cRows - 1].Bounds;
                var edgeLength = neBounds.Northeast.Latitude - neBounds.Southwest.Latitude;
            }

            return(blocks);
        }
Ejemplo n.º 11
0
        //得到的结果是:x坐标,y坐标,区域编号
        public static GeoRegion LatLonToUTM(double lat, double lon, int zone, double offset)
        {
            //double zone = Math.Floor((lon + 180.0) / 6) + 1;

            double cm = UTMCentralMeridian(zone);

            double[] xy = new double[2];

            MapLatLonToXY(lat / 180.0 * pi, lon / 180 * pi, cm, out xy);

            /* Adjust easting and northing for UTM system. */
            xy[0] = xy[0] * UTMScaleFactor + 500000.0;
            xy[1] = xy[1] * UTMScaleFactor;
            if (xy[1] < 0.0)
            {
                xy[1] = xy[1] + 10000000.0;
            }

            var region = new GeoRegion()
            {
                EastMin  = xy[0] - offset,
                Eastmax  = xy[0] + offset,
                NorthMin = xy[0] - offset,
                NorthMax = xy[0] + offset
            };

            return(region);
            //return new double[] { xy[0], xy[1], zone };
        }
 private List <ExmGeoData> GetGeoData(Dictionary <int, int> weightedIDs)
 {
     return(weightedIDs.Select(weightedId => new ExmGeoData()
     {
         Weight = weightedId.Value / 100.0, WhoIs = GeoRegion.RandomCountryForSubRegion(weightedId.Key)
     }).ToList());
 }
Ejemplo n.º 13
0
        /// <summary>
        /// 编辑范围
        /// </summary>
        /// <param name="Region"></param>
        public void UpdateRegionREQ(GeoRegion Region, string SchemaName, string TaskName)
        {
            try
            {
                //EditRegion rEditRegion = new EditRegion();
                //rEditRegion.ShowDialog();

                //if (rEditRegion.UpdateRegion == true)
                //{
                //Create a new EditTaskRegionRequest Object and create a new message GUID
                EditTaskRegionRequest rEditTaskRegionRequest = new EditTaskRegionRequest();
                rEditTaskRegionRequest.itemID = Guid.NewGuid();

                //set the schema name, task name and the region.
                rEditTaskRegionRequest.SchemaName = SchemaName;                       //IDC_SCHEMA_COMBO.SelectedItem.ToString();
                rEditTaskRegionRequest.TaskName   = TaskName;                         // IDC_TASK_COMBO.SelectedItem.ToString();
                rEditTaskRegionRequest.EastMin    = Convert.ToInt32(Region.EastMin);  // Convert.ToInt32(rEditRegion.IDC_EASTMIN.Text);
                rEditTaskRegionRequest.EastMax    = Convert.ToInt32(Region.Eastmax);  // Convert.ToInt32(rEditRegion.IDC_EASTMAX.Text);
                rEditTaskRegionRequest.NorthMin   = Convert.ToInt32(Region.NorthMin); // Convert.ToInt32(rEditRegion.IDC_NORTHMIN.Text);
                rEditTaskRegionRequest.NorthMax   = Convert.ToInt32(Region.NorthMax); // Convert.ToInt32(rEditRegion.IDC_NORTHMAX.Text);
                JLog.Instance.Info(string.Format(" {0} {1} {2} {3}", rEditTaskRegionRequest.EastMin, rEditTaskRegionRequest.EastMax, rEditTaskRegionRequest.NorthMin, rEditTaskRegionRequest.NorthMax));
                JLog.Instance.AppInfo(string.Format("添加EWAW请求--编辑仿真范围任务序号:{0}", rEditTaskRegionRequest.itemID));
                GlobalInfo.Instance.JobsRunning[rEditTaskRegionRequest.itemID] = rEditTaskRegionRequest;
                //GlobalInfo.Instance.JobsRunning.Add(rEditTaskRegionRequest.itemID, rEditTaskRegionRequest);
                //Call RequestEditTaskRegion passing rEditTaskRegionRequest as a parameter
                m_EAWSClient.EditRequest(rEditTaskRegionRequest);
                //}
            }
            catch (Exception ex)
            {
                JLog.Instance.Error(ex.Message, MethodBase.GetCurrentMethod().Name,
                                    MethodBase.GetCurrentMethod().Module.Name);
            }
        }
Ejemplo n.º 14
0
 public override void writeTo(GeoWriter writer, bool l2j)
 {
     GeoRegion.putType(writer, l2j, getType());
     writer.putShort(_cells[0].getHeight());
     if (!l2j)
     {
         writer.putShort(_cells[0].getHeight());
     }
 }
Ejemplo n.º 15
0
    private bool Inside(Vector3 point, GeoRegion region)
    {
        PosRot  center  = region.transform.posRot;
        bool    box     = region.shape == GeoRegion.GeoShape.box;
        float   radius  = region.sphereRadius + GEOM_DELTA;
        Vector3 extents = region.extents + 2f * GEOM_DELTA * Vector3.one;

        return(UFUtils.Inside(point, center, radius, extents, box));
    }
Ejemplo n.º 16
0
        public void LoadRegion(GeoRegion region, ProgressEvent ev)
        {
            vis_tree.ClearTree();
            models.Clear();
            //
            setTreeBounds(region);
            //
            int      x, y, i = 0;
            int      max = REGION_SIZE * REGION_SIZE;
            GeoBlock block;
            Vector3  min = new Vector3();

            for (y = 0; y < REGION_SIZE; y++)
            {
                for (x = 0; x < REGION_SIZE; x++)
                {
                    block = region.getBlockByBlockXY(x, y);
                    foreach (GeoModel m in createBlock(block))
                    {
                        if (i == 0)
                        {
                            min = m.Position;
                        }
                        else
                        {
                            if (m.Position.X < min.X)
                            {
                                min.X = m.Position.X;
                            }
                            if (m.Position.Y > min.Y)
                            {
                                min.Y = m.Position.Y;
                            }
                            if (m.Position.Z < min.Z)
                            {
                                min.Z = m.Position.Z;
                            }
                        }
                        //
                        i++;
                    }
                    //
                    if (ev != null)
                    {
                        float p = (y * REGION_SIZE + x) / (float)max;
                        ev((int)(p * 100f));
                    }
                }
            }
            //
            Camera.Rotation.X = 45f;
            Camera.Position.X = min.X - 20f;
            Camera.Position.Z = min.Z - 20f;
            Camera.Position.Y = min.Y + 20f;
            Camera.UpdateWorldView();
        }
Ejemplo n.º 17
0
        private void buttonX3_Click_1(object sender, EventArgs e)
        {
            WGS84ToUTM.Exute(null);
            var baseInfo = ucLTEStationType1.BuildBasicInfo();

            baseInfo.Lng = 119.97;
            baseInfo.Lat = 31.81;
            GeoRegion reg = new GeoRegion();
            //PLAData.GetExtend(baseInfo.Lng,baseInfo.Lat, out reg.EastMin,out reg.Eastmax,out reg.NorthMin,out reg.NorthMax, r*1000,50);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 渐变模式改变的事件响应
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void comboBoxFillGradientMode_TextChanged(object sender, EventArgs e)
        {
            try
            {
                GeoRegion region = pictureBoxFill.Tag as GeoRegion;
                String    text   = comboBoxFillGradientMode.Text;

                if (text == "None")
                {
                    region.Style.FillGradientMode            = FillGradientMode.None;
                    comboBoxFillGradientAngle.Enabled        = false;
                    comboBoxFillGradientOffsetRatioX.Enabled = false;
                    comboBoxFillGradientOffsetRatioY.Enabled = false;
                    checkBoxFillBackOpaque.Enabled           = true;
                }
                if (text == "Linear")
                {
                    region.Style.FillGradientMode            = FillGradientMode.Linear;
                    comboBoxFillGradientAngle.Enabled        = true;
                    comboBoxFillGradientOffsetRatioX.Enabled = true;
                    comboBoxFillGradientOffsetRatioY.Enabled = false;
                    checkBoxFillBackOpaque.Enabled           = false;
                }
                if (text == "Conical")
                {
                    region.Style.FillGradientMode            = FillGradientMode.Conical;
                    comboBoxFillGradientAngle.Enabled        = true;
                    comboBoxFillGradientOffsetRatioX.Enabled = true;
                    comboBoxFillGradientOffsetRatioY.Enabled = true;
                    checkBoxFillBackOpaque.Enabled           = false;
                }
                if (text == "Radial")
                {
                    region.Style.FillGradientMode            = FillGradientMode.Radial;
                    comboBoxFillGradientAngle.Enabled        = true;
                    comboBoxFillGradientOffsetRatioX.Enabled = true;
                    comboBoxFillGradientOffsetRatioY.Enabled = true;
                    checkBoxFillBackOpaque.Enabled           = false;
                }
                if (text == "Square")
                {
                    region.Style.FillGradientMode            = FillGradientMode.Square;
                    comboBoxFillGradientAngle.Enabled        = true;
                    comboBoxFillGradientOffsetRatioX.Enabled = true;
                    comboBoxFillGradientOffsetRatioY.Enabled = true;
                    checkBoxFillBackOpaque.Enabled           = false;
                }
                DrawSymbol(m_symbol, region, pictureBoxFill.Size.Width - 20, pictureBoxFill.Size.Height - 40, pictureBoxFill);
                m_fillStyle.FillGradientMode = region.Style.FillGradientMode;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 19
0
 public override void writeTo(GeoWriter writer, bool l2j)
 {
     GeoRegion.putType(writer, l2j, getType());
     for (int x = 0, y; x < GeoEngine.GEO_BLOCK_SHIFT; x++)
     {
         for (y = 0; y < GeoEngine.GEO_BLOCK_SHIFT; y++)
         {
             writer.putShort(_cells[indexOf(x, y)].getHeightAndNSWE());
         }
     }
 }
Ejemplo n.º 20
0
        private DatasetVector DatasetConvertRegionToLine(DatasetVector dtVector2)
        {
            DatasetVector dtVector = null;

            if (dtVector2 != null)
            {
                DatasetVectorInfo dvi = new DatasetVectorInfo();
                dvi.Name = m_selLayer.Dataset.Datasource.Datasets.GetAvailableDatasetName("C_geoLine");
                dvi.Type = DatasetType.Line;

                //DatasetVector
                dtVector = m_selLayer.Dataset.Datasource.Datasets.Create(dvi);
                foreach (FieldInfo fi in dtVector2.FieldInfos)
                {
                    if (dtVector.FieldInfos.IndexOf(fi.Name) < 0 && !fi.IsSystemField)
                    {
                        dtVector.FieldInfos.Add(fi.Clone());
                    }
                }

                Recordset recdst = dtVector.GetRecordset(true, CursorType.Dynamic);

                recdst.Batch.Begin();
                try
                {
                    Recordset recdst2 = dtVector2.GetRecordset(false, CursorType.Static);
                    while (!recdst2.IsEOF)
                    {
                        GeoRegion geoR = recdst2.GetGeometry() as GeoRegion;

                        if (geoR != null)
                        {
                            GeoLine geoLine = geoR.ConvertToLine();
                            recdst.AddNew(geoLine);
                            foreach (FieldInfo fi in dtVector2.FieldInfos)
                            {
                                if (dtVector.FieldInfos.IndexOf(fi.Name) > -1 && !fi.IsSystemField)
                                {
                                    recdst.SetFieldValue(fi.Name, recdst2.GetFieldValue(fi.Name));
                                }
                            }
                            geoR.Dispose();
                        }
                        recdst2.MoveNext();
                    }
                    recdst2.Dispose();
                }
                catch { }
                recdst.Batch.Update();
                recdst.Dispose();
            }
            return(dtVector);
        }
Ejemplo n.º 21
0
 public override bool dataEquals(GeoReader reader)
 {
     if (getType() != GeoRegion.getType(reader, true))
     {
         return(false);
     }
     if (_cells[0].getHeight() != reader.getShort())
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 22
0
        /// <summary>
        /// 打开需要的工作空间文件及地图
        /// </summary>
        private void Initialize()
        {
            try
            {
                //初始化点线面
                m_point = new GeoPoint(25, 25);

                Point2Ds point2DsLine = new Point2Ds();
                point2DsLine.Add(new Point2D(5, 35));
                point2DsLine.Add(new Point2D(65, 35));
                m_line = new GeoLine(point2DsLine);

                Point2Ds point2DsRegion = new Point2Ds();
                point2DsRegion.Add(new Point2D(5, 5));
                point2DsRegion.Add(new Point2D(5, 69));
                point2DsRegion.Add(new Point2D(69, 69));
                point2DsRegion.Add(new Point2D(69, 5));
                m_region = new GeoRegion(point2DsRegion);
                //初始化点线面符号的风格
                m_markerGeoStyle            = new GeoStyle();
                m_markerGeoStyle.LineColor  = Color.Blue;
                m_markerGeoStyle.MarkerSize = new Size2D(12, 12);
                m_point.Style = m_markerGeoStyle;

                m_lineGeoStyle           = new GeoStyle();
                m_lineGeoStyle.LineColor = Color.Blue;
                m_lineGeoStyle.LineWidth = 0.5;
                m_line.Style             = m_lineGeoStyle;

                m_fillGeoStyle = new GeoStyle();
                m_fillGeoStyle.FillForeColor  = Color.Blue;
                m_fillGeoStyle.FillBackOpaque = false;
                m_region.Style = m_fillGeoStyle;

                // 得到点线面的RootGroup
                Resources     resources           = m_workspace.Resources;
                SymbolLibrary symbolMarkerLibrary = resources.MarkerLibrary;
                m_symbolMarkerRootGroup = symbolMarkerLibrary.RootGroup;

                SetTreeGroup(m_symbolMarkerRootGroup);

                SymbolLibrary symbolLineLibrary = resources.LineLibrary;
                m_symbolLineRootGroup = symbolLineLibrary.RootGroup;

                SymbolLibrary symbolFillLibrary = resources.FillLibrary;
                m_symbolFillRootGroup = symbolFillLibrary.RootGroup;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Ejemplo n.º 23
0
 /// <summary>
 /// 垂直偏移量改变的事件响应
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void comboBoxFillGradientOffsetRatioY_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         GeoRegion region = pictureBoxFill.Tag as GeoRegion;
         region.Style.FillGradientOffsetRatioY = comboBoxFillGradientOffsetRatioY.SelectedIndex;
         DrawSymbol(m_symbol, region, pictureBoxFill.Size.Width - 20, pictureBoxFill.Size.Height - 40, pictureBoxFill);
         m_fillStyle.FillGradientOffsetRatioY = region.Style.FillGradientOffsetRatioY;
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
            protected override void Process()
            {
                Engine geo = Engine.getInstance();

                geo.unload();
                geo.reloadGeo(X, Y, false);
                //
                GeoRegion region = geo.getActiveRegion();

                Scene.LoadRegion(region, progress_event);
                //
                List <DomainData> domains = getDomains();

                Scene.SetDomains(domains);
            }
Ejemplo n.º 25
0
        //-----------------------------

        private void setTreeBounds(GeoRegion region)
        {
            Vector3 min     = new Vector3();
            Vector3 max     = new Vector3();
            Vector2 geo_min = new Vector2();
            Vector2 geo_max = new Vector2();

            region.GetBounds(ref geo_min, ref geo_max);
            min.X = geo_min.X;
            min.Y = GEO.HEIGHT_MIN_VALUE;
            min.Z = geo_min.Y;
            max.X = geo_max.X;
            max.Y = GEO.HEIGHT_MAX_VALUE;
            max.Z = geo_max.Y;
            vis_tree.SetTreeBounds(ref min, ref max);
        }
Ejemplo n.º 26
0
 internal GeoRegion Clip(GeoRegion poly)
 {
     GeoRegion polygon = new GeoRegion();
     if (poly.Bounds.IntersectsWith(this.boundary))
     {
         foreach (Point2DCollection points in poly.Parts)
         {
             Point2DCollection item = this.Clip(points);
             if (item != null)
             {
                 polygon.Parts.Add(item);
             }
         }
     }
     return polygon;
 }
        protected void GeoReferenceForPoly(List <LatLong> rgll, string szCountry, string szAdmin)
        {
            if (rgll == null)
            {
                throw new ArgumentNullException(nameof(rgll));
            }
            if (szCountry == null)
            {
                throw new ArgumentNullException(nameof(szCountry));
            }

            if (!rgll.Any())
            {
                throw new InvalidOperationException("No latitude/longitudes in rgll!");
            }


            // Get the bounding box.
            LatLongBox llb = new LatLongBox(rgll.First());

            foreach (LatLong ll in rgll)
            {
                llb.ExpandToInclude(ll);
            }

            IEnumerable <airport> rgap = AdminAirport.UntaggedAirportsInBox(llb);
            GeoRegion             geo  = new GeoRegion(string.Empty, rgll);

            int cAirports = 0;

            foreach (AdminAirport ap in rgap)
            {
                if (geo.ContainsLocation(ap.LatLong))
                {
                    UpdateString.AppendLine(String.Format(CultureInfo.InvariantCulture, "UPDATE airports SET Country='{0}' {1} WHERE type='{2}' AND airportID='{3}';", szCountry, String.IsNullOrWhiteSpace(szAdmin) ? string.Empty : String.Format(CultureInfo.InvariantCulture, ", admin1 = '{0}' ", szAdmin), ap.FacilityTypeCode, ap.Code));
                    ap.SetLocale(szCountry, szAdmin);
                    cAirports++;
                }
            }

            if (cAirports > 0)
            {
                AuditString.AppendLine(String.Format(CultureInfo.CurrentCulture, "Updated {0} airports for country {1}, region {2}", cAirports, szCountry, szAdmin));
            }
        }
Ejemplo n.º 28
0
        public void GeoPolygon_Bounds()
        {
            GeoPolygon poly;

            poly = new GeoPolygon(
                new GeoCoordinate[] {
                new GeoCoordinate(10, 20),
                new GeoCoordinate(0, 20),
                new GeoCoordinate(0, 0)
            });

            Assert.AreEqual(new GeoRectangle(10, 20, 0, 0), poly.Bounds);

            // Verify that bounds are restored after serialization

            poly = (GeoPolygon)GeoRegion.Parse(poly.ToString());
            Assert.AreEqual(new GeoRectangle(10, 20, 0, 0), poly.Bounds);
        }
Ejemplo n.º 29
0
 /// <summary>
 /// 填充背景色按钮的事件响应
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void buttonFillBackColor_Click(object sender, EventArgs e)
 {
     try
     {
         if (colorDialog4.ShowDialog() == DialogResult.OK)
         {
             GeoRegion region = pictureBoxFill.Tag as GeoRegion;
             region.Style.FillBackColor    = colorDialog4.Color;
             buttonFillBackColor.BackColor = colorDialog4.Color;
             DrawSymbol(m_symbol, region, pictureBoxFill.Size.Width - 20, pictureBoxFill.Size.Height - 40, pictureBoxFill);
             m_fillStyle.FillBackColor = region.Style.FillBackColor;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Ejemplo n.º 30
0
        /// <summary>
        /// Navigates the <see cref="XamGeographicMap"/> to specified geographic region of the world
        /// </summary>
        /// <param name="geoMap">an instance of XamGeographicMap</param>
        /// <param name="geoRegion">a geographic region of the world</param>
        public static void NavigateTo(this XamGeographicMap geoMap, GeoRegion geoRegion)
        {
            var windowRect = geoMap.GetZoomFromGeographic(geoRegion.NorthWest.ToPoint(), geoRegion.SouthEast.ToPoint());

            // conversion of geographic region to window rect works when XamGeographicMap view was initialized
            if (windowRect == new Rect(0, 0, 1, 1))
            {
                geoMap.GridAreaRectChanged += (o, e) =>
                {
                    windowRect        = geoMap.GetZoomFromGeographic(geoRegion.NorthWest.ToPoint(), geoRegion.SouthEast.ToPoint());
                    geoMap.WindowRect = windowRect;
                };
            }
            else
            {
                geoMap.WindowRect = windowRect;
            }
        }
Ejemplo n.º 31
0
 public override bool dataEquals(GeoReader reader)
 {
     if (getType() != GeoRegion.getType(reader, true))
     {
         return(false);
     }
     //
     for (int x = 0, y; x < GeoEngine.GEO_BLOCK_SHIFT; x++)
     {
         for (y = 0; y < GeoEngine.GEO_BLOCK_SHIFT; y++)
         {
             if (_cells[indexOf(x, y)].getHeightAndNSWE() != reader.getShort())
             {
                 return(false);
             }
         }
     }
     return(true);
 }
Ejemplo n.º 32
0
		/// <summary>
		/// 在查询结果面板上初始化查询结果列表
		/// </summary>
		/// <param name="type">查询方式,默认为属性查询-Attribute,空间查询-Spatial</param>
		private void ExecuteQueryListBox(string type, Point3Ds TempPoints3Ds=null, string actionStr=null)
		{
			string layerName = "";
			if (this.QueryLayerList.Items.Count > 0)
			{
				layerName = this.QueryLayerList.SelectedValue.ToString();
			}
			
			if (layerName != "")//关键字为空时查询全部要素
			{
				string queryTxt = this.QueryNameTxt.Text.Trim();
				Workspace ws = MainWindow.m_workspace;
				if (ws != null)
				{
					string sourceName = ConfigurationManager.AppSettings.Get(queryDataSource);
					Datasource dSource = ws.Datasources[sourceName];
					if (dSource != null)
					{
						DatasetVector dSetV = (DatasetVector)dSource.Datasets[layerName];
						if (dSetV != null)
						{
							string fieldName = ConfigurationManager.AppSettings.Get(queryNameField);
							string fieldCode = ConfigurationManager.AppSettings.Get(queryCodeField);
							Recordset recordset = null;

							if (type != ATTRIBUTE_QUERY)
							{
								double queryBuffer = 0.0;
								SuperMap.Data.Geometry queryGeometry = null;
								
								switch (actionStr)
								{
									case "createpoint":
                                        queryBuffer = 0.01;
										if (TempPoints3Ds.Count == 1)
										{
											GeoPoint geoPoint = new GeoPoint(TempPoints3Ds[0].X, TempPoints3Ds[0].Y);
											queryGeometry = geoPoint;
										}
										break;
									case "createline":
										if (TempPoints3Ds.Count == 2)
										{
											Point2D point2D = new Point2D(TempPoints3Ds[0].X, TempPoints3Ds[0].Y);
                                            Point2D point2D1 = new Point2D(TempPoints3Ds[1].X, TempPoints3Ds[1].Y);
                                            double radius = Geometrist.Distance(new GeoPoint(point2D), new GeoPoint(point2D1));
                                            GeoCircle geoCircle = new GeoCircle(point2D, radius);
                                            GeoRegion geoRegion = geoCircle.ConvertToRegion(72);
                                            queryGeometry = geoRegion;
										}
										break;
									case "createpolygon":
										if (TempPoints3Ds.Count > 2)
										{
											Point2Ds tempPoint2Ds = new Point2Ds();
											for (int i = 0; i < TempPoints3Ds.Count; i++)
											{
												tempPoint2Ds.Add(new Point2D(TempPoints3Ds[i].X, TempPoints3Ds[i].Y));
											}
											GeoRegion geoRegion = new GeoRegion(tempPoint2Ds);
											queryGeometry = geoRegion;
										}
										break;
									default:
										break;
								}
                                if (queryGeometry != null)
                                {
                                    recordset = dSetV.Query(queryGeometry, queryBuffer, SuperMap.Data.CursorType.Static);
                                }
							}
							else
							{
								QueryParameter queryParameter = new QueryParameter();
								queryParameter.CursorType = SuperMap.Data.CursorType.Static;
								queryParameter.HasGeometry = true;
								if (this.QueryNameTxt.Text.Trim() != "")
								{
									queryParameter.AttributeFilter = fieldName + " like '%" + queryTxt + "%'";
								}

								recordset = dSetV.Query(queryParameter);
							}
							
							if (recordset != null && recordset.RecordCount > 0)
							{
								ObservableCollection<QueryRecordVO> recordList = SysModelLocator.getInstance().recordList;
								recordList.Clear();
								bool isExist = false;
								FieldInfos fis = recordset.GetFieldInfos();
								for (int j = 0; j < fis.Count; j++)
								{
									FieldInfo fi = fis[j];
									if (fi != null)
									{
										if (fi.Name.ToString().ToUpper() == fieldName)
										{
											isExist = true;
											break;
										}
										continue;
									}
								}

								if (isExist)
								{
									for (recordset.MoveFirst(); recordset.IsEOF == false; recordset.MoveNext())
									{
										QueryRecordVO qVO = new QueryRecordVO();
										qVO.RecordLayerId = layerName;
										qVO.RecordName = recordset.GetFieldValue(fieldName).ToString();
										qVO.RecordIndex = recordset.GetFieldValue(fieldCode).ToString();
										qVO.RecordCenterX = recordset.GetGeometry().InnerPoint.X.ToString();
										qVO.RecordCenterY = recordset.GetGeometry().InnerPoint.Y.ToString();
										recordList.Add(qVO);
									}
									this.QueryListBox.ItemsSource = recordList;
									this.QueryInfo.Text = "查询结果合计:" + recordList.Count + "条";
								}
								else
								{
									this.QueryListBox.ItemsSource = null;
									this.QueryInfo.Text = "";
								}
							}
							else
							{
                                SysModelLocator.getInstance().recordList.Clear();
								this.QueryListBox.ItemsSource = null;
								this.QueryInfo.Text = "查询结果合计:0条";
							}
						}
					}
				}
			}
		}