PostGIS point convert to npgSql point problem

Topics: SharpMap v2.0
Mar 20, 2012 at 10:37 AM
Edited Mar 20, 2012 at 11:21 AM

Hi,everyone:

      when I Use postGIS privider to do analysis of intersection,the point in my shapefile like "Point(5 5)", are converted into the pattern like"Point z(5 5.00000 0.00006)". So,  the Points with the value"Point(5 5)"in the shapfile stored in the PostGIS can't be found. however, when I use SQLServer2008 and SQlite, those points with value"Point(5 5)" could be found. How can I solve the problem? thanks for any tips!

I find the spatialreferences are different. the Point spatialreference is "GEOGCS["WGS 84", DATUM["WGS_1984", SPHEROID["WGS 84", 6378137, 298.257223563, AUTHORITY["EPSG", "7030"]], TOWGS84[0, 0, 0, 0, 0, 0, 0], AUTHORITY["EPSG", "6326"]], PRIMEM["Greenwich", 0, AUTHORITY["EPSG", "8901"]], UNIT["degree", 0.0174532925199433, AUTHORITY["EPSG", "9122"]], AUTHORITY["EPSG", "4326"]]"

and the provider sparialreference is "
GEOGCS["WGS 84", DATUM["WGS_1984", SPHEROID["WGS 84", 6378137, 298.257223563, AUTHORITY["EPSG", "7030"]], AUTHORITY["EPSG", "6326"]], PRIMEM["Greenwich", 0, AUTHORITY["EPSG", "8901"]], UNIT["degree", 0.0174532925199433, AUTHORITY["EPSG", "9122"]], AUTHORITY["EPSG", "4326"]]"

                SpatialBinaryExpression spExpression = SpatialBinaryExpression.Intersects(geometryFactory.CreatePoint2D(5, 5));
                FeatureQueryExpression featureQuery = new FeatureQueryExpression(spExpression);
                IFeatureDataReader featureDatareader = spPoint.ExecuteFeatureQuery(featureQuery);
Coordinator
Mar 21, 2012 at 12:29 PM

Could you raise an issue and provide a test case, please

Thanks FObermaier

Mar 22, 2012 at 3:26 AM

thanks for your reply. I use postGis1.5 for postGresSql9.1 to load my shapfile with the srtext ""GEOGCS["WGS 84", DATUM["WGS_1984", SPHEROID["WGS 84", 6378137, 298.257223563, AUTHORITY["EPSG", "7030"]], TOWGS84[0, 0, 0, 0, 0, 0, 0], AUTHORITY["EPSG", "6326"]], PRIMEM["Greenwich", 0, AUTHORITY["EPSG", "8901"]], UNIT["degree", 0.0174532925199433, AUTHORITY["EPSG", "9122"]], AUTHORITY["EPSG", "4326"]]"".

But I find the srtext in the PostGis is "GEOGCS["WGS 84", DATUM["WGS_1984", SPHEROID["WGS 84", 6378137, 298.257223563, AUTHORITY["EPSG", "7030"]], AUTHORITY["EPSG", "6326"]], PRIMEM["Greenwich", 0, AUTHORITY["EPSG", "8901"]], UNIT["degree", 0.0174532925199433, AUTHORITY["EPSG", "9122"]], AUTHORITY["EPSG", "4326"]]",there is no "TOWGS84[0, 0, 0, 0, 0, 0, 0]".

so, when I do spatial operation, the  "Provider.SpatialReference.EqualParams(geom.SpatialReference)" will return false and my geometry will be transformed. the "Point(5 5)" becomes "Point Z(5 5.00000002 0.0000000012)".

I replaced the srtext in spartialreference table in the postGIs with the srtext including "TOWGS84[0, 0, 0, 0, 0, 0, 0]",the Point Intersection could get the right results.

I don't know know if you understand what I said. My English is poor.

 protected IGeometry TransformGeometry(IGeometry geom)
        {
            if (geom.SpatialReference == null || Provider.SpatialReference == null)
                return geom;

            if (!Provider.SpatialReference.EqualParams(geom.SpatialReference))
            {
                if (Provider.CoordinateTransformationFactory == null)
                    throw new MissingCoordinateTransformationFactoryException(
                        "Data requires transformation however no CoordinateTransformationFactory is set");

                ICoordinateTransformation ct =
                    Provider.CoordinateTransformationFactory.CreateFromCoordinateSystems(geom.SpatialReference,
                                                                                         Provider.
                                                                                             OriginalSpatialReference);

                return ct.Transform(geom, Provider.GeometryFactory);
            }
            return geom;
        }

Coordinator
Mar 23, 2012 at 10:37 AM
Edited Mar 23, 2012 at 10:38 AM

It seems that the EqualParams function of ICoordinateSystem should treat "TOWGS84[0,0,0,0,0,0,0]" as not set.
Are you using the version in trunk?

I see if I can fix that.