Ejemplo n.º 1
0
        private void Form_Load(object sender, EventArgs e)
        {
            // It is important to set the map unit first to either feet, meters or decimal degrees.
            mapView.MapUnit = GeographyUnit.Meter;

            // Create the background world maps using vector tiles requested from the ThinkGeo Cloud Service and add it to the map.
            ThinkGeoCloudVectorMapsOverlay thinkGeoCloudVectorMapsOverlay = new ThinkGeoCloudVectorMapsOverlay("itZGOI8oafZwmtxP-XGiMvfWJPPc-dX35DmESmLlQIU~", "bcaCzPpmOG6le2pUz5EAaEKYI-KSMny_WxEAe7gMNQgGeN9sqL12OA~~", ThinkGeoCloudVectorMapsMapType.Light);

            mapView.Overlays.Add(thinkGeoCloudVectorMapsOverlay);

            // Create a new overlay that will hold our new layer and add it to the map.
            LayerOverlay coyoteSightingsOverlay = new LayerOverlay();

            mapView.Overlays.Add(coyoteSightingsOverlay);

            // Create the new layer and set the projection as the data is in srid 2276 as our background is srid 3857 (spherical mercator).
            PostgreSqlFeatureLayer coyoteSightingsLayer = new PostgreSqlFeatureLayer("User ID=thinkgeo_user;Password=cs%^%#trsdFG;Host=sampledatabases.thinkgeo.com;Port=5432;Database=thinkgeo_samples;Pooling=true;", "frisco_coyote_sightings", "id", 2276);

            coyoteSightingsLayer.FeatureSource.ProjectionConverter = new ProjectionConverter(2276, 3857);

            // Add the layer to the overlay we created earlier.
            coyoteSightingsOverlay.Layers.Add("Coyote Sightings", coyoteSightingsLayer);

            // Set a point style to zoom level 1 and then apply it to all zoom levels up to 20.
            coyoteSightingsLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle   = new PointStyle(PointSymbolType.Circle, 12, GeoBrushes.Red, new GeoPen(GeoColors.White, 2));
            coyoteSightingsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            // Set the map view current extent to a bounding box that shows just a few sightings.
            mapView.CurrentExtent = new RectangleShape(-10784283.099060204, 3918532.598821122, -10781699.527518518, 3916820.409397046);

            // Refresh the map.
            mapView.Refresh();
        }
        public PostgreTableDataRepositoryItem()
        {
            Icon = new BitmapImage(new Uri("/GisEditorPluginCore;component/Images/table.png", UriKind.RelativeOrAbsolute));

            MenuItem propertyItem = new MenuItem();

            propertyItem.Icon    = DataRepositoryHelper.GetMenuIcon("/GisEditorPluginCore;component/Images/properties.png", 16, 16);
            propertyItem.Header  = "Properties";
            propertyItem.Command = new RelayCommand(() =>
            {
                LayerPlugin matchingLayerPlugin = GisEditor.LayerManager.GetActiveLayerPlugins <LayerPlugin>()
                                                  .FirstOrDefault(tmpPlugin => tmpPlugin.Name.Equals("PostgreSql", StringComparison.OrdinalIgnoreCase));

                PostgreSqlFeatureLayer newLayer = GetPostgreSqlFeatureLayers().FirstOrDefault();
                if (newLayer != null)
                {
                    UserControl userControl = matchingLayerPlugin.GetPropertiesUI(newLayer);

                    Window propertiesDockWindow = new Window()
                    {
                        Content       = userControl,
                        Title         = GisEditor.LanguageManager.GetStringResource("MapElementsListPluginProperties"),
                        SizeToContent = SizeToContent.WidthAndHeight,
                        ResizeMode    = System.Windows.ResizeMode.NoResize,
                        Style         = Application.Current.FindResource("WindowStyle") as System.Windows.Style
                    };

                    propertiesDockWindow.ShowDialog();
                }
            });
            ContextMenu.Items.Add(propertyItem);
        }
        private void WpfMap_Loaded(object sender, RoutedEventArgs e)
        {
            wpfMap1.MapUnit = GeographyUnit.DecimalDegree;

            wpfMap1.CurrentExtent = new RectangleShape(-126.4, 48.8, -67.0, 19.0);

            string connectString = "Server=192.168.0.235;User Id=userId;Password=password;DataBase=postgis;";
            PostgreSqlFeatureLayer postgreLayer = new PostgreSqlFeatureLayer(connectString, "new_states", "recid");
            postgreLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.Country1;
            postgreLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay postgreOverlay = new LayerOverlay();
            postgreOverlay.Layers.Add(new BackgroundLayer(new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean)));
            postgreOverlay.Layers.Add("PostgreLayer", postgreLayer);
            wpfMap1.Overlays.Add("PostgreOverlay", postgreOverlay);

            wpfMap1.Refresh();
        }
Ejemplo n.º 4
0
        protected override Collection <Layer> GetLayersCore(GetLayersParameters getLayersParameters)
        {
            Collection <Layer> layers = new Collection <Layer>();

            foreach (Uri uri in getLayersParameters.LayerUris)
            {
                string tableName        = uri.LocalPath.Split('|')[0];
                string schema           = uri.LocalPath.Split('|')[1];
                string connectionString = uri.LocalPath.Split('|')[2];
                string featureIdColumn  = uri.LocalPath.Split('|')[3];
                PostgreSqlFeatureLayer postgreSqlFeatureLayer = new PostgreSqlFeatureLayer(connectionString, tableName, featureIdColumn);
                postgreSqlFeatureLayer.SchemaName     = schema;
                postgreSqlFeatureLayer.Name           = postgreSqlFeatureLayer.TableName;
                postgreSqlFeatureLayer.CommandTimeout = Singleton <ServerFeatureLayerSettingsUserControl> .Instance.PostgreTimeoutInSecond;
                layers.Add(postgreSqlFeatureLayer);
            }

            return(layers);
        }
        private void MapView_Loaded(object sender, RoutedEventArgs e)
        {
            mapView.MapUnit = GeographyUnit.DecimalDegree;

            mapView.CurrentExtent = new RectangleShape(-126.4, 48.8, -67.0, 19.0);

            string connectString = "Server=54.177.171.109;User Id=postgres;Password=akeypmon1;DataBase=spatialdatabase;";
            PostgreSqlFeatureLayer postgreLayer = new PostgreSqlFeatureLayer(connectString, "COUNTRY02", "'RECID'");

            postgreLayer.SchemaName = "public";
            postgreLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = AreaStyle.CreateSimpleAreaStyle(GeoColor.FromArgb(255, 233, 232, 214), GeoColor.FromArgb(255, 118, 138, 69));
            postgreLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay postgreOverlay = new LayerOverlay();

            postgreOverlay.Layers.Add(new BackgroundLayer(new GeoSolidBrush(GeoColors.ShallowOcean)));
            postgreOverlay.Layers.Add("PostgreLayer", postgreLayer);
            mapView.Overlays.Add("PostgreOverlay", postgreOverlay);

            mapView.Refresh();
        }
        private void LoadPostgreLayer()
        {
            Controls.Clear();
            Controls.Add(winformsMap1);

            winformsMap1.MapUnit = GeographyUnit.DecimalDegree;

            winformsMap1.CurrentExtent = new RectangleShape(-126.4, 48.8, -67.0, 19.0);
            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);

            string connectString = "Server=192.168.0.235;User Id=userId;Password=password;DataBase=postgis;";
            PostgreSqlFeatureLayer postgreLayer = new PostgreSqlFeatureLayer(connectString, "new_states", "recid");

            postgreLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle    = AreaStyles.Country1;
            postgreLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            LayerOverlay staticOverlay = new LayerOverlay();

            staticOverlay.Layers.Add("PostgreLayer", postgreLayer);
            winformsMap1.Overlays.Add(staticOverlay);

            winformsMap1.Refresh();
        }
Ejemplo n.º 7
0
        protected override Uri GetUriCore(Layer layer)
        {
            PostgreSqlFeatureLayer postgreSqlFeatureLayer = (PostgreSqlFeatureLayer)layer;

            return(new Uri("postgreSqlFeatureLayer:" + postgreSqlFeatureLayer.ConnectionString + postgreSqlFeatureLayer.TableName));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Setup the map with the ThinkGeo Cloud Maps overlay. Also, add the PostgreSql layer to the map
        /// </summary>
        protected override void OnAppearing()
        {
            base.OnAppearing();
            // It is important to set the map unit first to either feet, meters or decimal degrees.
            mapView.MapUnit = GeographyUnit.Meter;

            // Create the background world maps using vector tiles requested from the ThinkGeo Cloud Service and add it to the map.
            var thinkGeoCloudVectorMapsOverlay = new ThinkGeoCloudVectorMapsOverlay("9ap16imkD_V7fsvDW9I8r8ULxgAB50BX_BnafMEBcKg~", "vtVao9zAcOj00UlGcK7U-efLANfeJKzlPuDB9nw7Bp4K4UxU_PdRDg~~", ThinkGeoCloudVectorMapsMapType.Light);

            thinkGeoCloudVectorMapsOverlay.VectorTileCache = new FileVectorTileCache(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "cache"), "CloudMapsVector");
            mapView.Overlays.Add(thinkGeoCloudVectorMapsOverlay);

            // Create a new overlay that will hold our new layer and add it to the map.
            LayerOverlay coyoteSightingsOverlay = new LayerOverlay();

            mapView.Overlays.Add(coyoteSightingsOverlay);

            // Create the new layer and set the projection as the data is in srid 2276 as our background is srid 3857 (spherical mercator).
            PostgreSqlFeatureLayer coyoteSightingsLayer = new PostgreSqlFeatureLayer("User ID=thinkgeo_user;Password=cs%^%#trsdFG;Host=sampledatabases.thinkgeo.com;Port=5432;Database=thinkgeo_samples;Pooling=true;", "frisco_coyote_sightings", "id", 2276);

            coyoteSightingsLayer.FeatureSource.ProjectionConverter = new ProjectionConverter(2276, 3857);

            // Add the layer to the overlay we created earlier.
            coyoteSightingsOverlay.Layers.Add("Coyote Sightings", coyoteSightingsLayer);

            // Set a point style to zoom level 1 and then apply it to all zoom levels up to 20.
            coyoteSightingsLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle   = new PointStyle(PointSymbolType.Circle, 12, GeoBrushes.Red, new GeoPen(GeoColors.White, 2));
            coyoteSightingsLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            // Set the map view current extent to a bounding box that shows just a few sightings.
            mapView.CurrentExtent = new RectangleShape(-10784283.099060204, 3918532.598821122, -10781699.527518518, 3916820.409397046);

            // Refresh the map.
            mapView.Refresh();

            #region Create Sample Data Code

            // ========================================================
            // Code for creating the sample data in PostgreSql
            // ========================================================

            //    Collection<FeatureSourceColumn> columns = new Collection<FeatureSourceColumn>();
            //    columns.Add(new FeatureSourceColumn("comment", "varchar", 255));

            //    PostgreSqlFeatureSource target = new PostgreSqlFeatureSource("User ID={username};Password={password};Host=10.10.10.179;Port=5432;Database=thinkgeo_samples;Pooling=true;", "frisco_coyote_sightings", "ID", 2276);
            //    target.Open();

            //    ShapeFileFeatureSource source = new ShapeFileFeatureSource(@"../../../data/Frisco_Coyote_Sightings.shp");
            //    source.Open();

            //    var sourceFeatures = source.GetAllFeatures(ReturningColumnsType.AllColumns);

            //    target.BeginTransaction();

            //    foreach (var feature in sourceFeatures)
            //    {
            //        var dict = new Dictionary<string, string>();
            //        dict.Add("comment", feature.ColumnValues["Comments"].ToString().Replace('"', ' ').Replace("'", ""));
            //        dict.Add("id", feature.ColumnValues["OBJECTID"]);
            //        var newFeature = new Feature(feature.GetWellKnownBinary(), feature.ColumnValues["OBJECTID"], dict);

            //        target.AddFeature(newFeature);
            //    }

            //    var results = target.CommitTransaction();
            //    target.Close();

            //    target.Open();
            //    var features = target.GetAllFeatures(ReturningColumnsType.AllColumns);
            //    target.Close();
            #endregion
        }