ThinkGeo.com    |     Documentation    |     Premium Support

Heatstlye and sql query

 hi


 help me please


1. draw heatmap radius by get heatStyle.PointRadius values from field in shape DBF


2. sql query find point in shapefile withindistance when draw circle show in gridview


thank you



form code content 2. sql query 
             PointShape pointShape = (PointShape)ViewState["CenterPoint"];

            double distance = Convert.ToDouble(DistanceDropDownList.SelectedItem.ToString(), CultureInfo.InvariantCulture);
            double latDiff = DecimalDegreesHelper.GetLatitudeDifferenceFromDistance(distance, DistanceUnit.Kilometer, pointShape.X);
            double longDiff = DecimalDegreesHelper.GetLongitudeDifferenceFromDistance(distance, DistanceUnit.Kilometer, pointShape.Y);
            string sql = "Select * from rabies1 where (6371 * acos(sin(LAT/" + 57.295800 + ") * sin(" + pointShape.Y / 57.295800 + ") + cos( LAT/" + 57.295800 + ") * cos(" + 13.61988 / 57.295800 + ") * cos(LONG/"+ 57.295800 +" - "+ pointShape.X/ 57.295800 + "))) > " + distance + "";
            LayerOverlay staticOverlay = (LayerOverlay)Map1.CustomOverlays["StaticOverlay"];
            ShapeFileFeatureLayer worldLayer4 = (ShapeFileFeatureLayer)staticOverlay.Layers["WorldLayer4"];

            // Find the countries within special distance.
            worldLayer4.Open();
             DataTable dataTable = worldLayer4.QueryTools.ExecuteQuery(sql);
            worldLayer4.Close();
            FeaturesGridView.DataSource = dataTable;
            FeaturesGridView.DataBind(); 
 


Hi dacha,


For your first question, you can override the HearStyle and set the Radius value for each feature,



    class MyHeatStyle : HeatStyle
    {
        public MyHeatStyle(string columnName, double startValue, double endValue)
            : base(columnName, startValue, endValue)
        { }

        protected override void DrawCore(IEnumerable<Feature> features, GeoCanvas canvas, Collection<SimpleCandidate> labelsInThisLayer, Collection<SimpleCandidate> labelsInAllLayers)
        {
            foreach (var item in features)
            {
                PointRadius = Convert.ToDouble(item.ColumnValues["Radius"]);
                base.DrawCore(new Feature[] { item }, canvas, labelsInThisLayer, labelsInAllLayers);
            }
        }
    }

 


For your second question, here is the code,



            PointShape pointShape = (PointShape)ViewState["CenterPoint"];

            double distance = Convert.ToDouble(DistanceDropDownList.SelectedItem.ToString(), CultureInfo.InvariantCulture);
             LayerOverlay staticOverlay = (LayerOverlay)Map1.CustomOverlays["StaticOverlay"];
            ShapeFileFeatureLayer worldLayer4 = (ShapeFileFeatureLayer)staticOverlay.Layers["WorldLayer4"];
           
            // Find the countries within special distance.
            worldLayer4.Open();
            Collection<Feature> foundFeatures = worldLayer4.FeatureSource.GetFeaturesWithinDistanceOf(pointShape, GeographyUnit.DecimalDegree, DistanceUnit.Meter,distance,     ReturningColumnsType.AllColumns);
            worldLayer4.Close();
            // 
            foreach(Feature feature in foundFeatures)
            {
                //add your own code to put the columns' value in feature into datatable
            }
  
            FeaturesGridView.DataSource = dataTable;
            FeaturesGridView.DataBind(); 


 


Hope it helps,


Edgar


 



from sql query  
    data in dbf set font thai when show on web "äÁ辺àª×éÍ(FA-)" 
   how to set font thai when show on web

Is your computer’s language English? I tried to convert the “äÁ辺àª×éÍ(FA-)”  to Thai with following code,

            string value = “äÁ辺àª×éÍ(FA-)”;
            //874 is Thai’s code page
            Encoding.GetEncoding(874).GetString(Encoding.GetEncoding(CultureInfo.CurrentCulture.TextInfo.OEMCodePage).GetBytes(value));

 
and I get the result “AŠ_ง…ฆx‚I(FA-)”, is it something in Thai? If so I think you can use the following code to convert it to Thai,

            for (int k = 0; k < table.Rows.Count; k++)
            {
                for (int j = 0; j < table.Rows[k].ItemArray.Length; j++)
                {
                    string value = table.Rows[k].ItemArray[j].ToString();
                    string valueInThai = Encoding.GetEncoding(874).GetString(Encoding.GetEncoding(CultureInfo.CurrentCulture.TextInfo.OEMCodePage).GetBytes(value));
                    table.Rows[k].ItemArray[j] = valueInThai;
                }
            }

 
Hope it helps,
Edgar

 



thank you 
 my sourcecode  
     foreach (Feature feature in foundFeatures)
            {
                //DataTable table = new DataTable();
                //add your own code to put the columns’ value in feature into datatable
                DataRow row = table.NewRow();
                for (int i = 0; i < table.Columns.Count; i++)
                {
                     row[i] =  feature.ColumnValues[table.Columns[i].ColumnName];
                }
                table.Rows.Add(row);
            } 
 
  
 i have change line :  row<i> =  feature.ColumnValues[table.Columns<i>.ColumnName]; 
             to  for (int j = 0; j < table.Rows[k].ItemArray.Length; j++)
                {
                    string value = table.Rows[k].ItemArray[j].ToString();
                    string valueInThai = Encoding.GetEncoding(874).GetString(Encoding.GetEncoding(CultureInfo.CurrentCulture.TextInfo.OEMCodePage).GetBytes(value));
                    table.Rows[k].ItemArray[j] = valueInThai;
                }
 
 it not work 


Oh, it’s not working like this, I thought you already have the DataTable with data filled in, now it seems the DataTable is initialized by the foundFeatures, please roll back to your code and set the “worldLayer4.Encoding = Encoding.GetEncoding(874);” and I think everything will be OK. 
  
 Regards, 
 Edgar

i have source code show multimap and shapefile point layer. i have question 
 1. when show heatmap (rabies1.shp) can set layer base on google map?  
 2. insert class heatstyles  and set radius from filed 
             if (!Page.IsPostBack)
            {
                Map1.MapBackground.BackgroundBrush = new GeoSolidBrush(GeoColor.FromHtml("#E5E3DF"));
                Map1.CurrentExtent = new RectangleShape(10000000, 2300000, 13200000, 400000);
                Map1.MapUnit = GeographyUnit.Meter;

                Map1.MapTools.OverlaySwitcher.Enabled = true;
                Map1.MapTools.MouseCoordinate.Enabled = true;
                Map1.MapTools.PanZoomBar.Enabled = true;
                Map1.MapTools.OverlaySwitcher.OnClientBaseOverlayChanged = "onLayerChanged";

                WmsOverlay wms = new WmsOverlay("WMS Overlay");
                wms.Parameters.Add("layers", "Countries02,USSTATES,USMAJORCITIES");
                wms.Parameters.Add("STYLE", "SIMPLE");
                wms.ServerUris.Add(new Uri("wmssamples.thinkgeo.com/WmsServer.aspx"));
                wms.SetBaseEpsgProjection("EPSG:900913");

                GoogleOverlay google = new GoogleOverlay("Google Map");
                google.GoogleMapType = GoogleMapType.Normal;
                google.JavaScriptLibraryUri = new Uri(ConfigurationManager.AppSettings["GoogleUriV3"]);

                OpenStreetMapOverlay osmOverlay = new OpenStreetMapOverlay("Open Street Map");

                YahooOverlay yahoo = new YahooOverlay("Yahoo Map");
                yahoo.YahooMapType = YahooMapType.Regular;
                yahoo.JavaScriptLibraryUri = new Uri(ConfigurationManager.AppSettings["YahooUri"]);

                BingMapsOverlay bing = new BingMapsOverlay("Bing Map");
                bing.MapType = ThinkGeo.MapSuite.WebEdition.BingMapsStyle.Road;

                ShapeFileFeatureLayer worldLayer1 = new ShapeFileFeatureLayer(MapPath("~/sharp/Changwat.shp"));
                worldLayer1.ZoomLevelSet = new GoogleMapsZoomLevelSet();
                worldLayer1.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(100, 212, 220, 184), GeoColor.FromArgb(255, 132, 132, 154), 1);
                worldLayer1.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level07;

                ShapeFileFeatureLayer worldLayer2 = new ShapeFileFeatureLayer(MapPath("~/sharp/Amphor.shp"));
                worldLayer2.ZoomLevelSet = new GoogleMapsZoomLevelSet();
                worldLayer2.ZoomLevelSet.ZoomLevel06.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(100, 212, 220, 184), GeoColor.FromArgb(255, 132, 132, 154), 1);
                worldLayer2.ZoomLevelSet.ZoomLevel06.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level12;

                ShapeFileFeatureLayer worldLayer3 = new ShapeFileFeatureLayer(MapPath("~/sharp/tambon.shp"));
                worldLayer3.ZoomLevelSet = new GoogleMapsZoomLevelSet();
                worldLayer3.ZoomLevelSet.ZoomLevel08.DefaultAreaStyle = AreaStyles.CreateSimpleAreaStyle(GeoColor.FromArgb(100, 212, 220, 184), GeoColor.FromArgb(255, 132, 132, 154), 1);
                worldLayer3.ZoomLevelSet.ZoomLevel08.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

                //pushpin shapefile
                ShapeFileFeatureLayer worldLayer4 = new ShapeFileFeatureLayer(MapPath("~/sharp/rabies1.shp"));
                worldLayer4.ZoomLevelSet = new GoogleMapsZoomLevelSet();
                worldLayer4.ZoomLevelSet.ZoomLevel01.DefaultPointStyle = PointStyles.CreateSimpleCircleStyle(GeoColor.StandardColors.Black, 7, GeoColor.StandardColors.White);
                worldLayer4.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;


                //InMemoryMarkerOverlay markerOverlay = new InMemoryMarkerOverlay();
                //ShapeFileFeatureSource featureSource = new ShapeFileFeatureSource(MapPath("~/sharp/rabies.shp"));
                //featureSource.CustomColumnFetch += new EventHandler<CustomColumnFetchEventArgs>(featureSource_CustomColumnFetch);

                Proj4Projection proj4 = new Proj4Projection();
                proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326);
                proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();
                worldLayer1.FeatureSource.Projection = proj4;
                worldLayer2.FeatureSource.Projection = proj4;
                worldLayer3.FeatureSource.Projection = proj4;

                //ปักหมุดตำแหน่งเกิดโรค
                worldLayer4.FeatureSource.Projection = proj4;
                
                LayerOverlay worldOverlay = new LayerOverlay("WorldOverlay");
                worldOverlay.Layers.Add(worldLayer1);
                worldOverlay.Name = "ThinkGeo Map";
                worldOverlay.SetBaseEpsgProjection("EPSG:900913");

                LayerOverlay shapeOverlay = new LayerOverlay("จังหวัด", false, TileType.SingleTile);
                shapeOverlay.Layers.Add(worldLayer1);
                shapeOverlay.TransitionEffect = TransitionEffect.None;

                LayerOverlay shapeOverlay1 = new LayerOverlay("อำเภอ", false, TileType.SingleTile);
                shapeOverlay1.Layers.Add(worldLayer2);
                shapeOverlay1.TransitionEffect = TransitionEffect.None;

                LayerOverlay shapeOverlay2 = new LayerOverlay("ตำบล", false, TileType.SingleTile);
                shapeOverlay2.Layers.Add(worldLayer3);
                shapeOverlay2.TransitionEffect = TransitionEffect.None;

                //pushpin shapefile
                LayerOverlay shapeOverlay3 = new LayerOverlay("จุดเกิดโรคพิษสุนัขบ้า", false, TileType.SingleTile);
                shapeOverlay3.Layers.Add(worldLayer4);
                shapeOverlay3.TransitionEffect = TransitionEffect.None;

                //heatlayer
                //HeatLayer heatLayer = new HeatLayer(featureSource);
                //heatLayer.HeatStyle = new HeatStyle("intensityColumnName", 0.1, 10);

                //LayerOverlay heatlayerOverlay = new LayerOverlay("Heat", false, TileType.SingleTile);
                //heatlayerOverlay.IsBaseOverlay = false;
                //heatlayerOverlay.Layers.Add(heatLayer);

                Map1.CustomOverlays.Add(osmOverlay);
                Map1.CustomOverlays.Add(google);
                Map1.CustomOverlays.Add(yahoo);
                Map1.CustomOverlays.Add(bing);
                //Map1.CustomOverlays.Add(worldOverlay);
                Map1.CustomOverlays.Add(shapeOverlay);
                Map1.CustomOverlays.Add(shapeOverlay1);
                Map1.CustomOverlays.Add(shapeOverlay2);
                Map1.CustomOverlays.Add(shapeOverlay3);
                //Map1.CustomOverlays.Add(heatlayerOverlay);

                Map1.ZoomLevelSet = worldLayer1.ZoomLevelSet;

            }
        }
        //heatlayer
        //private void featureSource_CustomColumnFetch(object sender, CustomColumnFetchEventArgs e)
        //{
        //    e.ColumnValue = e.Id;
        //}
    }
 
  
 thank you

thank you support front thai

You’re welcome, for your questions,  
 1, yes you can, set the googleoverlay as baseoverlay,  
 2, could you please make it clearer?  
  
 Thanks, 
 Edgar

2. i have field radius values 0.1 - 1.0 in dbf and from answer 3 draw radius from field values. please example code insert answer 8 
  
 thank you

Dacha,


Here is the code for HeatLayer, I assume you want to use the worldLayer4 as the source of heatLayer.



                HeatLayer heatLayer = new HeatLayer(worldlayer4.FeatureSource);
                heatLayer.HeatStyle = new MyHeatStyle("intensityColumnName", 1, 10);
                LayerOverlay heatlayerOverlay = new LayerOverlay();
                heatlayerOverlay.IsBaseOverlay = false;
                heatlayerOverlay.Layers.Add(heatLayer);

Using this code, you can draw the circles in different radius.


Regards,


Edgar



thank you so much

why when build project. show message "out of memory"

Is the "out of memory" come from after building or running? Could you please send us your project to forumsupport@thinkgeo.com?  
  
 Thanks, 
 Edgar

i sent project to you  
 thank you

Dacha,


The reason of “out of memory” is the winformsMap1.CurrentExtent is too large and the point on the screen is too small to draw. So you need to use a small enough winformsMap1.CurrentExtent, in that way you can see the circles. Attached is the screenshot about the shape file we used to test.


Regards,


Edgar



post10849.PNG (12 KB)

hi i dacha 
 from screenshot. i need to show same screenshot. and form source code sent to you. how can be modify source code that?  i can sent sharpfile to you test run?

and then  i have module calculate values circle and want update by used sql query in all data row in dbf. how to coding?

You can send your file to forumsupport@thinkgeo.com 
  
 Regards, 
 Edgar