I have a business requirement to store geometry data as WKT text value - varchar(max) in the SQL table; geometry and geography datatype can NOT be used. Is there any way I can load MsSql2008FeatureLayer with WKT value? How can this be achieved? What are other alternatives?
Would appreciate a fast response. Thanks in advance.
I think in current version of Map Suite, we do not support a Table without Geometry column defined. When you create a MsSql2008FeatureLayer using any constructors, exception will be thrown out when you called the Open API if no geometry column is not found.
One solution for this problem is probably to create a brand new FeatureSource and FeatureLayer which may need to rewrite at least the following Cores, this will probably take several days to have a try to see if it works.
OpenCore
GetFeaturesInsideBoundingBoxCore
GetAllFeaturesCore
If you want, you could contact our support to see if you could get the Source code of this related classes, I remember we have a similar product called MapSuite Source Kit exposing those classes, which will help you a lot to build up the new FeatureSource and FeatureLayer.
2. Since you are not using the built in spatial function of SQL the source for that layer and feature source would probably not do you much good. It would be better to create your own FeatureSource and FeatureLayer to accomplish this. We have a very good video on how to do this at the link below. Since you will need to store the geometry as WKT then you will need to add some other fields for the bounding box otherwise your query will be very slow. If you cannot do this then you need to check each feature which will be slow.
3. If you rather we work on this you can use our professional services. You can outline the requirements and we can build you the custom feature source and custom feature layer. I recommend this because it seems your requirements are outside the normal realm. Of course if you are familiar with SQL Server then building your own classes should not be that hard after watching the video.
Of course we will do whatever we can here to answer questions.
2. Like I said before if you only have one column with WKT then it will be hard to query that to find what items need to be displayed. If you however can add another few columns such as UpplerLeftX as double, UpperLeftY as double, LowerRightX as double and LowerRightY as double then I think we could quickly build you a prototype to read your WKT. You will need these other columsn to be able to quickly find the records based on the bounding box.
I saw in your e-mail to support that you had another issue that was not posted here. See the quote below.
Quote: "I have a problem with original MsSql2008FeatureLayer. It does not accept nothing else but the tableName, while instead of tableName I need to query SQL with a parameter (e.g. SELECT * FROM TableName WHERE SpeciesID = 35)."
To solve this issues you can intercept an event which is raised right before we execute the SQL statement. In this event you can modify the SQL to include whatever extra where clause entries you need. You can see an explanation and sample of this at the link below.