VERIFIED SOLUTION i
X

Resolve issue where the MapXtreme FeatureGeometryFromWKT method is reusing same object reference

Issue

There's a class in MXT called "MapInfo.OGC.FeatureGeometryFactory" with a method called "FeatureGeometryFromWKT".

If you pass a Well Known Text string to "FeatureGeometryFromWKT", it returns a properly constructed Feature Geometry Object.

However, if you pass a second Well Known Text string to the "FeatureGeometryFromWKT" you notice that the first variable is changed.

It appears that the MapInfo.OGC.FeatureGeometryFactory.FeatureGeometryFromWKT() method always returns an object with the same object reference.

If it is called repeatedly with different input WKT strings and assigned to a different variable each time, when you are done, all the variables are set to the result of the last WKT string.

This is not what we would expect any function to do.

 

Cause

This is Work as Designed. Please refer to below documentation.

"The methods that create FeatureGeometry instances from either Well Known Text or Well Known Binary are instance methods.

Constructing a FeatureGeometryFactory requires a coordinate system.

Each conversion will interpret the x and y data values in terms of that coordinate system and the FeatureGeometry returned will reference that coordinate system.

Users are encouraged to reuse the same factory as much as possible as this will enable the most efficient reuse of parsing memory which will be used in building the returned FeatureGeometry objects.

This means, however, that the FeatureGeometry objects returned are only valid while the factory that created them is still active (for example, has not been garbage collected) and no other call to convert either Well Known Text or Well Known Binary has been made.

If a FeatureGeometry object is needed longer than this scope, the returned FeatureGeometry should be copied by calling CopyFeatureGeometry."

 

Resolution

UPDATED: September 5, 2017


One can use CopyFeatureGeometry if a different object is required.

Environment Details

MapXtreme

Downloads

  • No Downloads