Reproject shapefile

Jan 18, 2015 at 9:46 PM
Edited Jan 18, 2015 at 11:16 PM
I'm working in an app that needs to load shapefiles.

For that, I'm loading the .PRJ file to check if the projection is WGS84 as my code was designed to deal with that projection. If it is not WGS84 I'm converting to it.

I'm creating a new ProjectionInfo object from that file:
GEOGCS["Puerto Rico",DATUM["D_Puerto_Rico",SPHEROID["Clarke_1866",6378206.4,294.9786982]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
I'm comparing the datum from PRJ file with the WGS84 which is what I'm using to perform calculations in my code.
If they don't match I convert the shapefile to WGS84:
            If Not SourceProjection.Equals(DestinationProjection) Then
                Projections.Reproject.ReprojectPoints() ...
            End If
The problem is that after converting the file, the coordinates are equal to the input.

I tracked the issue and I found something weird:

Inside the ReprojectPoints() there is that code:

                if (!source.GeographicInfo.Datum.Matches(dest.GeographicInfo.Datum))
                {
                    DatumTransform(source, dest, xy, z, startIndex, numPoints);
                }
Looking closer to the method .Matches() you can find that:
        /// <summary>
        /// Compares two datums to see if they are actually describing the same thing and
        /// therefore don't need to be transformed.
        /// </summary>
        /// <param name="otherDatum">The other datum to compare against</param>
        /// <returns>The boolean result of the operation.</returns>
        public bool Matches(Datum otherDatum)
        {
            if (_datumtype != otherDatum.DatumType) return false;
            if (_datumtype == DatumType.WGS84) return true;
What is the reason for that line?
if (_datumtype == DatumType.WGS84) return true;
The line seems to be the reason why nothing is converted when I input the PRJ file (described above) and try to get new coordinates converted to WGS84.

When I input DATUM["D_Puerto_Rico",SPHEROID["Clarke_1866
ProjectionInfo says that it is WGS84 but spheroid is different then the coordinates of shapefile must be reprojected.
But the result of Reproject.ReprojectPoints() seems to be the same as input.

Am I missing something ?