I occasionally get the following error in my Desktop application:
"There’re some invalid geometry instance in table not valid. About
invalid geometry please have aThe look at
msdn.microsoft.com/en-us/library/bb933890.aspx website. To solve
this problem, we provide MakeAllGeometryValid function to make the
invalid geometry to be valid, because of the function updating your
data, you need to backup your data before using this function."
1) Your main search isn’t working - typing ‘MakeAllGeometryValid’ into the ‘Search ThinkGeo.com’ field at the top of the page currently results in:
"The specified request cannot be executed from current Application Pool"
2) What is this MakeAllGeometryValid function anyway? It is not mentioned in the Wiki anywhere apart from mentioning that you make it. Where is is and how is it used? Speciically I am interested in knowing how to find my invalid point or line out of the millions of SQL Server objects that are in the database.
3) I am not using any geometry objects actually - only using geography objects. I presume the error is relying on some underlying geometry within the geography objects?
MakeAllGeometryValid function
Hi David,
Thanks for let us know the problem, it’s outdate and we should forgot to edit the text, we don’t have the function MakeAllGeometryValid now.
From the link in exception message, if this geometry is invalid we should want to reference the Microsoft.SqlServer.Types, and call SqlGeometry.MakeValid function to fix it. (msdn.microsoft.com/zh-cn/library/microsoft.sqlserver.types.sqlgeometry.makevalid.aspx)
I don’t think our code can implement that, that should is better works in SqlServer side.
And I found another topic about this, it looks this exception maybe caused by other reason for example missed srid in query. Please see whether it’s helpful for you.
thinkgeo.com/forums/MapSuite/tabid/143/aft/4903/Default.aspx
Regards,
Don
Thanks for the answer. I think that solves 1, 2 & 3.
As far as 4, I don’t think that other link helps much - I am not using shape files and my Geography objects are very simple - either single points or simple lines between 2 points (not polylines). So, there shouldn’t be any problem with shape files creating invalid complex shapes like donuts or whatever. The project has a few million records in SQL Server with a few thousand more coming in every day. This problem only occurs every few weeks. My main aim is to find out why it happens so I can stop it happening in the future, rather than patching up afterwards so am hoping that the SqlGeometry.MakeValid function will help.
It still seems as though I will have to convert the geography to geometry to do that though…
Hi David,
Could you please provide us some shapes which can recreate the issue? we need the data to analyze why they are invalid. You don’t need to send us the whole project or data, some simple “valid” shapes would be fine, you can send them with wkt string.
Thanks,
Troy
Therein lies the problem. As I originally said:
“Specifically I am interested in knowing how to find my invalid point or line out of the millions of SQL Server objects that are in the database.”
I was hoping that a MakeAllGeometryValid function would somehow highlight the bad record so I could have a look at it. I don’t see a way to have MapSuite find the bad record - SQL Server Management Studio quite happily shows all the spatial data without complaining but MapSuite brings up the error seemingly in a normal WinformsMap1.Refresh(LayerName) statement with no indication of which of the millions of records is at fault.
Hi David,
This exception will be thrown in two functions, we catch deeper exception and throw this one, so we cannot make sure what’s the detail information now.
But I found we still save the original information in the new exeption, so if possible could you please copy the detail exception information if you met that when debug, so we can make sure where throw original exception and find how to locate the record invalid.
Regards,
Don
Ok, next time it happens I will copy the information and report back here - it doesn’t happen that often so might be some days or weeks.
Hi David,
Thanks for let us know this problem, because we haven’t met that before so we don’t have solution for it now.
If you met this problem again, please paste the detail information here, that should be helpful for us to locate which code throw this exception.
Regards,
Don