Select to view content in your preferred language

Robust way for testing geometric equivalence

584
2
Jump to solution
04-30-2013 09:31 PM
GinoMellino
Frequent Contributor
Hi all,

Can I please get some advice as to how to use IRelationalOperator on geometries from different layers with different spatial references? I have a routine which gets a test and base feature cursor from 2 layers and then iterates through each feature in the test cursor and compares it to each feature in the base cursor using IRelationalOperator::Equals to determine if a match is found. This works perfectly if the features have the same spatial reference. However if I get the same layer and export it into a different spatial reference then the routine will return False for all features.

I have tried assigning the IFeautre:Shapecopy to an IGeometry, setting the .Spatial Reference and then calling IGeometry::Project but still am not having any luck.

Any advice is appreciated.

Thanks guys
0 Kudos
1 Solution

Accepted Solutions
NeilClemmons
Honored Contributor
When you copy the geometry and project it, you don't set the spatial reference.  The call to Project will update the spatial reference for you.  If you set the spatial reference and then call Project it will not do anything because it uses the spatial reference property to know what coordinate system it is projecting from.

View solution in original post

0 Kudos
2 Replies
NeilClemmons
Honored Contributor
When you copy the geometry and project it, you don't set the spatial reference.  The call to Project will update the spatial reference for you.  If you set the spatial reference and then call Project it will not do anything because it uses the spatial reference property to know what coordinate system it is projecting from.
0 Kudos
GinoMellino
Frequent Contributor
Neil, once again you have saved me, it is working beautifully.

I now use IGeoDataset::SpatialReference to obtain the spatial reference of the base layer and then call IGeometry::Project using this spatial reference for the features in the test layer.

Many thanks.
Gino
0 Kudos