ThinkGeo.com    |     Documentation    |     Premium Support

Custom Format and other problem

Hi, 


I have many questions and please reply me, thank you.


Q1. Your component supports custom format? If I create custom format, your component can support it?


Q2. Beside shape file, your component supports which file format? Why I ask this question because my shapefile size is large and many type files (river, country, roadtype1, roadtype2, mark, city, bridge, …ect). I want to know if there is any format that your component supports and it can combine total of my data (no matter its type is polygon, line, point). Could you give me some advice?


Q3. I want to my users can’t open my shape files by other component. I just allow my shape files are opened by my application. Colud you support any method by your component? (like encrypt my shape files?)


Q4. I install mapsuite desktop edition 3.1.299  in windows 7, it shows some messages: Public ReadOnly Property InternalFeatures() As ThinkGeo.MapSuite.Core.GeoCollection(Of ThinkGeo.MapSuite.Core.Feature) is obsolete: You are bypassing the automatic spatial indexing if the modify, add or delete. You need to call BuildIndex method later. Is there has any problem? (My program can run, but I don’t know why it shows these messages.)



 


Chen,
 
Welcome to Map Suite’s world!
 
A1. Yes. Our DesktopEdition support custom format, you can look at HowDoI samples after you install the package, it contains a specific catalog for Extending MapSuite. We also have online video and sample code to teach you how to integrate custom data formats, you can find them at gis.thinkgeo.com/Products/GI...fault.aspx
If your custom format follows our pattern, you can support it.
 
A2. I can not list all file formats we support, because they’re so many. The main files we support are ShapeFile, GridFile, Postgre, SQL2008, OracleSpatial, GoogleMap, Bing Map, Mr.Sid, ECW, JPEG2000, BMP, TIFF and all data formats from FDO etc. The more information you can look at
gis.thinkgeo.com/Support/Dis...fault.aspx
 
A3. I think your requirement can implement by extend our ShapeFileFeatureSource.
 
A4. Don’t care that warnings, it will be fixed in next version. It’s tough to explain in a few words.
 
Please let me know if you have more questions.
James

Sorry, I’m late to reply this article. 
 thank you, James 
 Q1. I’m not sure you said “custom data formats” is the same means as I said. 
 if i create a new data format called abc.aa (aa is a file format name that does not exist. thie file format just i know how to open it) 
 does i can modify featuresource code to read it? (sorry, i’m not very understand how to use mapsuite component, i just want to make sure this component can do something which i want or not) 
  
 Q2. as you said, if i want to combine all shape type to one file, i have to use image type or database, right? but, how can i know which type of map I load?(i just know each.shp file have its shape type, for example, road is lineshape, county is polygon shape…etc, but there have to divide many different shp file) so, if i combine all data to database, how do i load data and combine your component to show map?  
  
 Q3. could you give me a sample? 
  
 Q4. OK.

 


Chen,
 
 I hope the following answers can help you
 
A1. Sure, you can do it. What you need to do is to create your own ExtendFeatureSource class inherited from FeatureSource and overwrite some methods (GetAllFeaturesCore, OpenCore, CloseCore ...etc) using your own logic to open your own data format.
 
A2. As every ShapeFile can only have one type, you cannot merge city and road to one shape file. But you can add different types of features to a database like Sql2008 or Oracle. You can call MsSql2008FeatureLayer.EditTools.Add(feature) for adding and after all data is added, you can use the method Feature.GetWellKnownType() to get the type of one feature, which can be point, polyline, etc. 
 
A3. Please have a look at the following thread for it. This is not a great way for the encryption, it just works fine for simple shape files. We will work on it later to get a better way for the encryption.
    gis.thinkgeo.com/Support/Dis...fault.aspx
 
 
Please let me know if you have more questions.
James

James, thanks for your answer 
  
 Q1. I know your component supports many useful mehtods to compute data (for example, SpatiqlQuery, GetFeatureNearestTo, GetAllFeatures, ExecuteQuery,etc). If I create custom format, Do I have to modify all method(i means all method include Spatial Query()?) could you give me a rule that let me know what kind of method i have to modify? 
 Please tell me more information about how to use custom format. 


Chen, 
  
 Your question is good, I think you have done some research, otherwise you could not ask this question. 
  
 During the design time of MapSuite 3.0, we have already thought about the same thing, to let the users easy to integrate their custom data and implement all functions they want, we try to made the abstract methods as less as possible in base classes, so the users just need to override a few methods that still can work. For example, your requirement is that you want to inherit FeatureSource and define your custom FeatureSource which uses your own data, you just need override one method GetAllFeaturesCore,  if this method’s logic is correct, the other methods like you mentioned SpatialQuery, GetFeatureNearestTo, ExecuteQuery… etc. All of them can work properly because they call GetAllFeaturesCore inside their own code in FeatureSource. Only if you want to make the method more effective, you need to override it. 
  
 In our blog and code community, there are a lot of samples to show how to use custom format, have you ever watched our online video which I mentioned before? 
 I think you would be the expert after viewing them, but if you still feel it’s still not enough, please let me know. 
  
 Thanks 
 James 


Thank you, James 

i have watched powerpoint and sample code about custom data format. 

am i just modify some method like sample code shows? 

could you tell me why MinimumFeatureSource, MinimumFeatureLayer have to create? 



other question, 

if i use custom fodrmat and put all data(different shape type) in one file, does i have to create my own index file? 

i saw your API document has .buildindex mehtod. if i use my custom format, could i use this method? 

it can speed up load map? does it just used in shape file? 



do you have ever compare map performance (like pan, zoom,draw, etc.) between postgresql (or other database) and shape file? 



Please tell me more information about custom format. 

 



your sample of custom data format is point shape type. 
 could you give me a sample about polygon(has innerRing and outerRing) and line shape. 


Hi Chen,


At first, the MinimumFeatureSource and MinimumFeatureLayer are not necessary for a specific custom data format. The two classes are just show you how easily to write your own layer for your own data format, just implement one method, and then you can render your data using Map Suite. 
 
And you also don’t have to create index file for your own data format. The BuildIndex function is used for the existing data format in Map Suite, you need to implement your own index logic if you want to improve the performance of your own data format, but it is not necessary.
 
You can implement any shape type in your own feature layer, point, polygon, multipolygon, line and multiline, this is because a feature can contain data in any shape type, you just need to wrap your data in the return feature collection when you implement your own GetAllFeaturesCore method.
 
Hope this helps and any more questions please let us know.
 
Thanks,
 
Sun

Thank you, Sun 
 when i load data, how component to show the map? 
 i know i can set map scale. 
 for example, if i have data of city,town,marks,mainroad, secondroad, otherRoad1, otherRoad2, river,etc. and i set centerAt(80,-133), zoomlevel13 to show map. 
 how do you calculate range of map in zoomlevel13? 
 if zoomlevel13 is a rectangle range, are you just load data that included in this range?  
 or you still load all layer data and just draw map in this range? 
 when i pan, zoom in, zoom out the map, the component will re-call load map method? 
 please tell me more information about load data. because it related to the design of my database. 
 if any question above you don’t understand, please let me know. 


Has anyone to solve my problem? 


Chen, 



Here are my answers for your questions below: 



1, how do you calculate range of map in zoomlevel13? 



If you want to get the extent for a zoomlevel such as zoomlevel13, you can use the following code 



ZoomLevelSet zoomLevelSet = new ZoomLevelSet(); double scale = zoomLevelSet.ZoomLevel13.Scale; RectangleShape extent = ExtentHelper.ZoomToScale(scale, RectangleShape worldExtent, GeographyUnit worldExtentUnit, float screenWidth, float screenHight); 



2, if zoomlevel13 is a rectangle range, are you just load data that included in this range or you still load all layer data and just draw map in this range? 



Yes, we just load the data that includes in a special range. 



3, when i pan, zoom in, zoom out the map, the component will re-call load map method? 



Yes, it has to re-draw the map when you pan, zoom in, zoom out the map, if you want to increase the performance for loading data, you can use cache, here are the code for utilize cache: 




LayerOverlay staticOverlay = new LayerOverlay(); 
staticOverlay.Layers.Add("WorldLayer", worldLayer); 
winformsMap1.Overlays.Add(staticOverlay); 
FileBitmapTileCache bitmapTileCache = new FileBitmapTileCache(); 
bitmapTileCache.CacheDirectory = @"..\..\SampleData\Data\SampleCacheTiles";
bitmapTileCache.CacheId = "World02CachedTiles";
bitmapTileCache.ReadOnly = true; 
bitmapTileCache.ImageFormat = TileImageFormat.Png;
staticOverlay.TileCache = bitmapTileCache;



If you have any other questions please let me know, 



Thanks, 



Scott, 

 



Thanks for your answer… 
 BTW… 
 Could you give me sample to show polygon(contains inner ring, outer ring), lineshape that like your sample(use .mdb file) gis.thinkgeo.com/Products/GISComponentsforNETDevelopers/MapSuiteDesktopEdition/Videos/tabid/679/Default.aspx 
  
 ex. polygon{((33.25,15.01),(39.9998,25.0333),(59.33,26.22),(40.33,22.25),(33.25,15.01)),((35.22,15),(36.099,23),(38.999,36.11),(35.22,15))} 
 line{(33.255,21),(34.2222,22),(49.111,29),(55,22)}

Chen, 
  
 Actually, you already have the wkt text for polygon shape and line shape, then you can construct the polygon shape and line shape through the wkt texts; please see the sample code to show you the line shape construction and polygon shape construction, also the polygon shape is constructed by an outer ring and several inner rings, each ring shape is constructed by several points: 
  
 // Construct the line shape through line shape wkt.
            string lineWkt = "line{(33.255,21),(34.2222,22),(49.111,29),(55,22)}";
            LineShape line = new LineShape(lineWkt);

            // Constrct the polygon shape through polygon shape wkt.
            string polygonWkt = "polygon{((33.25,15.01),(39.9998,25.0333),(59.33,26.22),(40.33,22.25),(33.25,15.01)),((35.22,15),(36.099,23),(38.999,36.11),(35.22,15))}"; 
            PolygonShape polygon = new PolygonShape(polygonWkt);
            RingShape outerRing = polygon.OuterRing;
            Collection<RingShape> innerRings = new Collection<RingShape>();
            for (int i = 0; i < polygon.InnerRings.Count; i++)
            {
                innerRings.Add(polygon.InnerRings[i]);
            }
 
  
 Thanks, 
  
 Scott,

Thank you, Scott 
 but i have to modify string as follows. 
 string lineWkt = "linestring(33.255 21,34.2222 22,49.111 29,55 22)"; 
 LineShape line = new LineShape(lineWkt); 
 it works well. 
  
 as you said, your buildinex method just support the existing data format in Map Suite, 
 do you have any useful method for custom data format to create index file? 
  
 and i want to make sure MsSql2008FeatureSource supports msSql2008 server by spatial database or general database? 


Chen, 
  
 I am glad that it’s working with you, Thank Scott’s sharing. 
  
 I am afraid that we don’t have any method for creating custom index file, because as well known, the format of index file is according to the format of data file, we know the shape file’s format, so we can create index file for shape file, but we don’t know the format of custom data, so we can not create custom index file. And there are many ways to create the index file, each way will get the different file, for example, the shape file is very popular, every company supports this kind of data, but not any company creates the same index file, every one is different. Even our company uses two kinds of index file of shape file for different generation’s products as well. 
  
 MsSql2008FeatureSource supports spatial database. 
  
 James 


James / Chen, 
  
   In a few days we will expose our R-Tree file index class which enables you to create your own idx & sdx index files.  You could use that with your own custom data format.  As I said we are making them public and it will be in a development build in a few days. The official release won’t be until May but I am fairly sure the API will not change by then.  If you are interested then let us know. 
  
 David 
  


Thanks, James and David

that's a good news. (i hope i can get method of custom index)


about custom data format, i have probem...


My data format as follow attachments.

could you tell me how to modify GetFeaturesInsideBoundingBoxCore in your featureSoure sample.


i don't know how to set range of boundingbox of my data in line shape.


in Line 170 of OledbPointFeatureSource.cs (OledbPointFeatureSource.cs is your sample of custom data format),



string whereSql = " " + xColumnName + " <= " + boundingBox.LowerRightPoint.X + " AND " + xColumnName + " >= " + boundingBox.UpperLeftPoint.X + " AND " + yColumnName + " <= " + boundingBox.UpperLeftPoint.Y + " AND " + yColumnName + " >= " + boundingBox.LowerRightPoint.Y;


command = new OleDbCommand("SELECT " + idColumnName + " as TG_ID, " + xColumnName + " as TG_X, " + yColumnName + " as TG_Y " + columnsSQL + " FROM " + tableName + " WHERE " + whereSql, connection);

 

 



1652-Line.txt (1.4 KB)
1653-OledbPointFeatureSource.cs (12.9 KB)

Chen, 
  
 I am not very sure what you want. The boundingBox is a parameter that passes in from outside, that you don’t need modify the value of it, just use it in GetFeaturesInsideBoundingBoxCore method. 
  
 If you want to get the bounding box of a line shape, you can create an instance of LineShape by pass in the well known text, and then call the GetBoundingBox() method. 
 The attached file Line.txt is the list of well known text of line shapes. 
  
 Please let me know if you have more questions. 
  
 Thanks 
  
 James 


2, if zoomlevel13 is a rectangle range, are you just load data that included in this range or you still load all layer data and just draw map in this range? 



Yes, we just load the data that includes in a special range. 

↑ Sorry, I'm curious about this sentance. is it just support .shp file?


I use custom data format to load my coordinates.


but when i move my map(paning or zooming), it seems reload all coordinates.


what's wrong? or some method in featuresource have to modify??