ThinkGeo.com    |     Documentation    |     Premium Support

Need some simple clarifications

Hahai,,


i need some things to clarify from you guys. its simple things but its important for me.


1. Is it possible to show different bitmap icons to locate my points in single memory feature layer.. If so how to do that.


2. Am using two layer one is geotiffraster layer to display my map, and another one is memory feature layer to plot my points in my map.. but in this i can get the clicked feature in map click event.... Is it right type of layers type am using or else i want to change anythng let me know.... i cant get feature id or anything by findFeatureBy or anythng... why it occurs.


3.Then i need to draw custom shape on my plotted icons. how can i do this...


4. Is it geoTiff is much compatible with thinkGeo, coz all your samples are using shape file. i want to confirm that by using geotiff is it possible to acheive all the features in GIS component like what ever functionalities did using shape files??


  what is map engine.. 


Thanks











Hi deep,


 


Thanks for your post and questions.


 


I can give you some comments about your questions, hope this helps somehow.


 


1. Is it possible to show different bitmap icons to locate my points in single memory feature layer. If so, how to do that.


 


A: Yes, you could implement this functionality by ValueStyle. ValueStyle means different style can be set for different column values of a layer. So you just need to add a column to your InMemoryFeatureLayer, maybe called ValueType, and then you need to specify a value when you add a feature to this InMemoryFeatureLayer. So the features have different values in the ValueType column, maybe valueA, valueB etc. then you can specify the style for every kind of value. You could take a look at a HowDoISample located at HowDoISamples\Styles\DrawFeaturesBasedOnValues which is just tell you how to use ValueStyle.


 


2. Am using two layer one is geotiffraster layer to display my map, and another one is memory feature layer to plot my points in my map.. but in this i can get the clicked feature in map click event.... Is it right type of layers type am using or else i want to change anythng let me know....


 


A: If you want to display a GeoTiff image on the map control, the GeoTiffRasterLayer is just what you need. And the InMemoryFeatureLayer is convenient for your requirement. 


 


3.Then i need to draw custom shape on my plotted icons. how can i do this...


 


A: Do you mean track a shape on your map? You could take a look at the HowDoISample which locates at HowDoISamples\Editing Feature Layers\ TrackAndEditShapes. This sample shows you how to draw and edit a shape on the map.


 


4. Is it geoTiff is much compatible with thinkGeo, coz all your samples are using shape file. i want to confirm that by using geotiff is it possible to acheive all the features in GIS component like what ever functionalities did using shape files??


 


A: We also have a sample which is using a GeoTiff image. You can find it in HowDoISamples\Satellite image\LoadAStandardImageWithWorldFile. I don’t think GeoTiff is possible to achieve all the features in any GIS component like using shape files, because it is a raster data, different information stores in it from the shape file. Column information can not be used for raster data. There is also not shape information in the raster data, so the kind of GetFeatures and SpatialQuery functionalities can not be used for this type of data.


 


Hope this makes sense for you.


 


Any more questions please let us know.


 


Thanks,


 


Sun




Here in my code i cant add value style. where i can add value style. i need to add another icon in ploting map. and i want to draw polygon over my icon, am using below line. if i use ploygon i can am getting some temp value while bining the CustomColumnFetch 


 





wpfMap1.MapUnit = GeographyUnit.DecimalDegree;

            wpfMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);
            
            

            InMemoryFeatureLayer pointLayer = new InMemoryFeatureLayer();

            pointLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.PointType = PointType.Bitmap;
            pointLayer.ZoomLevelSet.ZoomLevel01.DefaultPointStyle.Image = new GeoImage(@"data\icon.bmp");
            pointLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
            pointLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("plotID", "Arial", 10, DrawingFontStyles.Regular, GeoColor.StandardColors.Red, -16, -20);
            pointLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle.BestPlacement = true;

            pointLayer.InternalFeatures.Add("Polygon", new Feature(BaseShape.CreateShapeFromWellKnownData("POLYGON((10 60,40 70,30 85, 10 60))")));

            GeoTiffRasterLayer mapLayer = new GeoTiffRasterLayer(@"data\mymap.tif");
            mapLayer.LowerThreshold = 0;
            mapLayer.UpperThreshold = double.MaxValue;

            mapLayer.Open();
            wpfMap1.CurrentExtent = mapLayer.GetBoundingBox();          
            mapLayer.Close();

            wpfMap1.MapClick += new EventHandler<MapClickWpfMapEventArgs>(wpfMap1_MapClick);
            pointLayer.FeatureSource.CustomColumnFetch += new EventHandler<CustomColumnFetchEventArgs>(FeatureSource_CustomColumnFetch);

            layerOverlay.Layers.Add("MapLayer", mapLayer);
            layerOverlay.Layers.Add("PointLayer", pointLayer);            
            wpfMap1.Overlays.Add("LayerOverlay", layerOverlay);

           
            wpfMap1.Refresh();



How can i draw semicircle above my located icon??? i mean i plotted features











Hi deep,


 


To add a ValueStyle for a layer, you need specify a column name for the ValueStyle. The code could be like this:


 



InMemoryFeatureLayer pointLayer = new InMemoryFeatureLayer();
pointLayer.Open();
pointLayer.Columns.Add(new FeatureSourceColumn("PointType"));
pointLayer.Close();

// Draw features based on values
ValueStyle valueStyle = new ValueStyle();
valueStyle.ColumnName = "PointType";

PointStyle pointStyle1 = new PointStyle(new GeoImage(@"data\icon1.bmp"));
PointStyle pointStyle2 = new PointStyle(new GeoImage(@"data\icon2.bmp"));
PointStyle pointStyle3 = new PointStyle(new GeoImage(@"data\icon3.bmp"));

valueStyle.ValueItems.Add(new ValueItem("1", pointStyle1));
valueStyle.ValueItems.Add(new ValueItem("2", pointStyle2));
valueStyle.ValueItems.Add(new ValueItem("3", pointStyle3));

pointLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle);
pointLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

 


And to draw a semicircle, I want to know if the semicircle is just an image or a shape (PolygonShape like the ellipse). If it is an image, you can simply set the image to the PointStyle for your plotted point. If it is a shape, I think you need to construct a WKT for it by the pivot and radius.


 


Hope this helps and any more questions please let us know.


 


Thanks,


 


Sun




Sun,


am not using image to plot my semi circle. thinking of drawing semicircle using polygon. how can i do that in the above given code


like below i have to draw above my plotted points. the radius may varies. plz give some sample code


      /'''''''/'


   /   /


//



Deep,


Thanks for your post and questions.
 
Following code snippet shows you how to get a semi-circle, based on the logic, you could get quarter-circle, or semi-ellipse etc.

EllipseShape circle = new EllipseShape(new PointShape(85, 10),15,15);
PolygonShape circlePolygon = circle.ToPolygon();
PolygonShape semiCirclePolygon = new PolygonShape();
            
int count = circlePolygon.OuterRing.Vertices.Count;
for(int i = 0; i < count/2;i++)
{   
   semiCirclePolygon.OuterRing.Vertices.Add(circlePolygon.OuterRing.Vertices[i]);
}
 
inMemoryLayer.InternalFeatures.Add("Semicircle", new Feature(semiCirclePolygon));


 
 
Any more questions just feel free to let me know.
 
Thanks.
 
Yale

ya thanks. its working well.  but its placed in default location. i cant move tat semicircle to some other location. how to give location to plot the semicircle in particular location

Deep, 
  
 Thanks for your response. 
  
 If you want to move the semicircle, just set a new center point for the Ellipse.  
  
 Thanks. 
  
 Yale 




 private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            loadMap();

            locatePoint(708.3900, -195.0750, "a");
            locatePoint(349.7953, -508.2320, "b");

        }

        public void loadMap()
        {
            wpfMap1.MapUnit = GeographyUnit.DecimalDegree;
            wpfMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);
            
            GeoTiffRasterLayer mapLayer = new GeoTiffRasterLayer(@"data\map.tif");
            mapLayer.LowerThreshold = 0;
            mapLayer.UpperThreshold = double.MaxValue;
           
            mapLayer.Open();
            wpfMap1.CurrentExtent = mapLayer.GetBoundingBox();
            mapLayer.Close();

            InMemoryFeatureLayer pointLayer = new InMemoryFeatureLayer();
            pointLayer.Open();
            pointLayer.Columns.Add(new FeatureSourceColumn("PointType"));
            pointLayer.Close();

            // Draw features based on values
            ValueStyle valueStyle = new ValueStyle();
            valueStyle.ColumnName = "PointType";

            PointStyle pointStyle1 = new PointStyle(new GeoImage(@"data\icon1.bmp"));
            PointStyle pointStyle2 = new PointStyle(new GeoImage(@"data\icon2.bmp"));
            PointStyle pointStyle3 = new PointStyle(new GeoImage(@"data\icon3.bmp"));

            valueStyle.ValueItems.Add(new ValueItem("1", pointStyle1));
            valueStyle.ValueItems.Add(new ValueItem("2", pointStyle2));
            valueStyle.ValueItems.Add(new ValueItem("3", pointStyle3));

            pointLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle);
            pointLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

            layerOverlay.Layers.Add("PointLayer", pointLayer);
          //  layerOverlay.Layers.Add("MapLayer", mapLayer);
                         
            
            wpfMap1.Overlays.Add("LayerOverlay", layerOverlay);


            wpfMap1.Refresh();
            
        }

        public void locatePoint(double x, double y, string key)
        {

            double longitude = Convert.ToDouble(x, CultureInfo.InvariantCulture);
            double latitude = Convert.ToDouble(y, CultureInfo.InvariantCulture);


            Feature feature = new Feature(longitude, latitude, key);
            InMemoryFeatureLayer pointLayer = (InMemoryFeatureLayer)wpfMap1.FindFeatureLayer("PointLayer");
                        
            if (!pointLayer.InternalFeatures.Contains(key))
            {
                pointLayer.InternalFeatures.Add(key, feature);               
            }

            wpfMap1.Refresh(wpfMap1.Overlays["LayerOverlay"]);

        }

 

am using the above code to loacte my points with different icons. but i cant view my points in my map…

deep, 
  
 I think you need set the PointType of PointStyle to bitmap if you want to display a image for point shape.  
 PointType = PointType.Bitmap; 
  
 For more information please let at our HowDoI sample "Draw A Point Using A Bitmap" 
  
 Please let me know if you have more questions. 
  
 Thanks 
 James

James,  
   i used point type bitmap also. but my problem is i need to show diff icons, but it showing only one icon in my loaded map.


 Deep, 
  
 Following sample in our code community shows you how to show different icons, just take a look at it if you are interested. 
 code.thinkgeo.com/projects/show/mapshapes 
  
 If you have any more questions just feel free to let me know. 
  
 Thanks. 
  
 Yale 


hai Yale, 
   
  Thanks for your reply. i already downloaded it and seen that sample. in that they used different map shape for different icons. but i need to use within oneInMemoryFeatureLayer . is it possible, i used value style in my layer for plotting different icons. but code running without any error. but my icons are not plotted in map.Plz see the code posted( 02-02-2010 02:03 AM ) in this thread above. is it possible to do like that. why my icons not plotted…

Deep,


Thanks for your post, I think there are 2 hidden problems in your code:
1)      Do not add the column value used in the ValueStyle.
2)      Set the wrong extent for the map control.
 
Try the following code:


private void DisplayASimpleMap_Loaded(object sender, RoutedEventArgs e)
        {
            loadMap();
 
            locatePoint(708.3900, -195.0750, "a");
            locatePoint(349.7953, -508.2320, "b");
        }
 
        public void loadMap()
        {
            wpfMap1.MapUnit = GeographyUnit.DecimalDegree;
            wpfMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);
 
            //GeoTiffRasterLayer mapLayer = new GeoTiffRasterLayer(@"data\map.tif");
            //mapLayer.LowerThreshold = 0;
            //mapLayer.UpperThreshold = double.MaxValue;
 
            //mapLayer.Open();
            //wpfMap1.CurrentExtent = mapLayer.GetBoundingBox();
            //mapLayer.Close();
 
            InMemoryFeatureLayer pointLayer = new InMemoryFeatureLayer();
            pointLayer.Open();
            pointLayer.Columns.Add(new FeatureSourceColumn("PointType"));
            pointLayer.Close();
 
            // Draw features based on values
            ValueStyle valueStyle = new ValueStyle();
            valueStyle.ColumnName = "PointType";
 
            PointStyle pointStyle1 = new PointStyle(new GeoImage(@"\Data\china.png"));
            PointStyle pointStyle2 = new PointStyle(new GeoImage(@"\Data\United States.png"));
            //PointStyle pointStyle3 = new PointStyle(new GeoImage(@"data\icon3.bmp"));
 
            valueStyle.ValueItems.Add(new ValueItem("1", pointStyle1));
            valueStyle.ValueItems.Add(new ValueItem("2", pointStyle2));
            //valueStyle.ValueItems.Add(new ValueItem("3", pointStyle3));
 
            pointLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle);
            pointLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
 
            LayerOverlay layerOverlay = new LayerOverlay();
 
            layerOverlay.Layers.Add("PointLayer", pointLayer);
            // layerOverlay.Layers.Add("MapLayer", mapLayer);
 
            wpfMap1.Overlays.Add("LayerOverlay", layerOverlay);
 
            pointLayer.Open();
            wpfMap1.CurrentExtent = pointLayer.GetBoundingBox();
            pointLayer.Close();
 
            //wpfMap1.Refresh();
 
        }
 
        public void locatePoint(double x, double y, string key)
        {
 
            double longitude = Convert.ToDouble(x, CultureInfo.InvariantCulture);
            double latitude = Convert.ToDouble(y, CultureInfo.InvariantCulture);
 
 
            Feature feature = new Feature(longitude, latitude, key);
            InMemoryFeatureLayer pointLayer = (InMemoryFeatureLayer)wpfMap1.FindFeatureLayer("PointLayer");
 
            if(string.Equals(key,"a", StringComparison.InvariantCulture))
            {
                feature.ColumnValues.Add("PointType","1");
            }
 
             if(string.Equals(key,"b", StringComparison.InvariantCulture))
            {
                feature.ColumnValues.Add("PointType","2");
            }
 
            if (!pointLayer.InternalFeatures.Contains(key))
            {
                pointLayer.InternalFeatures.Add(key, feature);
            }
 
            pointLayer.Open();
            wpfMap1.CurrentExtent = pointLayer.GetBoundingBox();
 
            wpfMap1.Refresh(wpfMap1.Overlays["LayerOverlay"]);
        }

 
If you have any more questions just feel free to let me know.
 
Thanks.
 
Yale

am getting the following error when i tried to run  
  
 Error : Value of ‘null’ is not valid for ‘stream’. 
  
 System.ArgumentException was unhandled 
   Message=“Value of ‘null’ is not valid for ‘stream’.” 
   Source=“DesktopEdition” 
   StackTrace: 
        at ThinkGeo.MapSuite.DesktopEdition.Overlay.Draw(GeoCanvas canvas) 
        at ThinkGeo.MapSuite.DesktopEdition.WpfMap.x03e3d48bcfe7bb6c(IEnumerable`1 xa6f0db4f183189f1) 
        at ThinkGeo.MapSuite.DesktopEdition.WpfMap.xff5b27c00f9678c2(RectangleShape x178b193eec228e6e) 
        at ThinkGeo.MapSuite.DesktopEdition.WpfMap.x742ba885258f6c2c(RectangleShape xb35a33b423b17f65, Overlay x99251f66cdabc2ad, Int32 xa209325f5c895f7e, Int32 x7454a0d1965919b1, GeographyUnit xbb704b4400ce6f76) 
        at ThinkGeo.MapSuite.DesktopEdition.WpfMap.x88c2a2d6d754e692(IEnumerable`1 xa6f0db4f183189f1) 
        at ThinkGeo.MapSuite.DesktopEdition.WpfMap.xe3cee4adb9c72451() 
        at ThinkGeo.MapSuite.DesktopEdition.WpfMap.x9ac8c50f434f4b39(Int32 xb565f4681f05557a) 
        at ThinkGeo.MapSuite.DesktopEdition.WpfMap.x4eb49068e137ed8f(InteractionArguments x195facd4ef5d753d) 
        at ThinkGeo.MapSuite.DesktopEdition.WpfMap.xfeca3317d3c75bbb(Object xd9272088e65bd176, x6a8380ab1a7ebb4c xc2fd4c0ed406cdb7) 
        at ThinkGeo.MapSuite.DesktopEdition.x5cd462d41be2f68a.OnMouseEvent(x6a8380ab1a7ebb4c e) 
        at ThinkGeo.MapSuite.DesktopEdition.x5cd462d41be2f68a.AnalyseMouseUp(Double screenX, Double screenY, Double worldX, Double worldY, MapMouseButton mouseButton) 
        at ThinkGeo.MapSuite.DesktopEdition.WpfMap.xfb2b8bdcd082873c(Object xd9272088e65bd176, MouseButtonEventArgs xc2fd4c0ed406cdb7) 
        at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) 
        at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) 
        at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) 
        at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted) 
        at System.Windows.Input.InputManager.ProcessStagingArea() 
        at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input) 
        at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport) 
        at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel) 
        at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) 
        at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) 
        at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled) 
        at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o) 
        at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter) 
        at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler) 
        at System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter) 
        at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam) 
        at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg) 
        at System.Windows.Threading.Dispatcher.TranslateAndDispatchMessage(MSG& msg) 
        at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) 
        at System.Windows.Application.RunInternal(Window window) 
        at TGEO.App.Main() in C:\Documents and Settings\dheebankumar\My Documents\Visual Studio 2008\Projects\TGEO\TGEO\obj\Debug\App.g.cs:line 0 
        at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) 
        at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() 
        at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) 
        at System.Threading.ThreadHelper.ThreadStart() 
   InnerException:  


deep, 
  
 That’s because the images is not existing, please change the code and use your images. 
  
 Thanks 
  
 James

ya got. thanks james.its working now. but i cant see the map. so when am enable these lines in the above code 
 even map is not viewable state. 
  
             GeoTiffRasterLayer mapLayer = new GeoTiffRasterLayer(@"data\map.tif"); 
             mapLayer.LowerThreshold = 0; 
             mapLayer.UpperThreshold = double.MaxValue; 
   
             mapLayer.Open(); 
             wpfMap1.CurrentExtent = mapLayer.GetBoundingBox(); 
             mapLayer.Close(); 
  
 If i disable my point layer in this two lines i can get my map,But i disabled my pointlayer so i cant get my points in my map. i cant view my pointlayer and maplayer at sametime. Why Whats the problem here… 
             layerOverlay.Layers.Add("MapLayer", mapLayer); 
            // layerOverlay.Layers.Add("PointLayer", pointLayer);

Deep, 
  
 I think the reason is your map.tif extent cannot compatible with the point layer extent. If you want, you could sent me the file , I can double check that for you. 
  
 Thanks. 
  
 Yale 


yale i solved it. thanks la.. some problem with tiff format. Another problem i facing. i found a excellent code for drawing pie shapes by Ryan here 

gis.thinkgeo.com/Support/DiscussionForums/tabid/143/aff/21/aft/5864/afv/topic/Default.aspx 



is it possible to make that pie shape as fixed one.




Thanks..