5 Replies Latest reply on Feb 29, 2012 9:15 PM by vbdeepak

    convert point xy coordinate from degree to metres

    choilon
      Hi folks,

      I have a map service which coordinate is in GDA94 and unit is in metre. I have created a point which performs spatial query.

      my code is simple

      localhost.PointN pPoint = new localhost.PointN();
      pPoint.X = m_x;
      pPoint.Y = m_y;

      when the point xy coordinate input is in metre, it works fine.

      my requirement right now is xy coordinate should be in degree.

      Does arcgis server soap api provide interface to transfer degree to metre.

      thanks
        • Re: convert point xy coordinate from degree to metres
          vbdeepak
          Hi choilon ,

          In Geometry service there is a method called "Project". With this method we can convert xy coordinates from Decimal Degrees to meters.
          public ESRI.ArcGIS.ADF.Web.Geometry.Point projection(ESRI.ArcGIS.ADF.Web.Geometry.Point point)
              {
          #region projection DECIMAL DEGREES TO METERS
                  string conection = ConfigurationManager.ConnectionStrings["geom"].ToString();

                  GeometryServerProxy gsp = new GeometryServerProxy("<geometryserver url>");
                  SpatialReference inputSpatialReference = new GeographicCoordinateSystem();
                  // WGS_1984(world) to Mercator
                  inputSpatialReference.WKID = 4326;// esriSRProjCS_WGS1984WorldMercator WGS 1984 World Mercator.
                  inputSpatialReference.WKIDSpecified = true;
                  SpatialReference outputSpatialReference = new ProjectedCoordinateSystem();
                  outputSpatialReference.WKID = 54004;
                  outputSpatialReference.WKIDSpecified = true;
                  GeoTransformation transformation = new GeoTransformation();
                  // esriSRProjCS_WGS1984WorldMercator TO WGS 1984 World Mercator. AND VICEVERSA
                  transformation.WKID = 1156;
                  transformation.WKIDSpecified = true;
                  ESRI.ArcGIS.ADF.ArcGISServer.Geometry[] inputGeometry = new ESRI.ArcGIS.ADF.ArcGISServer.Geometry[] { ESRI.ArcGIS.ADF.ArcGISServer.Converter.FromAdfPoint((point)) };
                  bool transformForward = false;
                  EnvelopeN extent = null;
                  ESRI.ArcGIS.ADF.ArcGISServer.Geometry[] outputGeometry = gsp.Project(inputSpatialReference, outputSpatialReference, transformForward, transformation, extent, inputGeometry);
                  ESRI.ArcGIS.ADF.Web.Geometry.Point webpt = ESRI.ArcGIS.ADF.ArcGISServer.Converter.ToAdfPoint(outputGeometry[0] as PointN);
                  return webpt;
                  #endregion
          }

          Try this by changing the input spatial reference and output spatial reference WKID

          Regards,
          Deepak.
          • Re: convert point xy coordinate from degree to metres
            ahoque-esristaff
            Choilon,
            You don't need to project your search shape for query operation.
            All you need to do is to define the spatialReference for the search shape.

            In you case, it should be something like
            pPoint.SpatialReference = aGCSProjection;


            When a search shape's (i.e. pPoint) SpatialReference is not defined, MapServer assumes it is in layer's projection. That's the reason your query is not returning any result.

            Tanu
            • Re: convert point xy coordinate from degree to metres
              choilon
              Thanks for reply. Actually I have tried to create a new geographiccoodinatesystem and sign to point's spatial reference. It still does not work.

              SpatialReference inputSpatialReference = new GeographicCoordinateSystem();
              inputSpatialReference.WKID = 4326;
              inputSpatialReference.WKIDSpecified = true;
              pPoint.spatialreference = inputSpatialReference

              The basic problem is my input point and map service use same coordinate system, but point's xy coordinate is in degree. Because the map service unit is in metre, it automatically take x,y input as metre rather than degree.

              Point.x = X; --- X is input in degree.

              Is there an interface or function can convert degree to metre in the same coordinate system?

              thanks,
              choilon
              • Re: convert point xy coordinate from degree to metres
                ahoque-esristaff

                The basic problem is my input point and map service use same coordinate system, but point's xy coordinate is in degree. Because the map service unit is in metre, it automatically take x,y input as metre rather than degree.

                Choilon,
                I'm afraid I haven't understood it correctly. You are saying your 'search point' and mapservice are in same coordinate system, but 'search point's coordinates are in degree whereas mapservice in meter!!

                Can you provide me a sample data/map and your code for me to take a look at?

                Thanks.

                Tanu
                • Re: convert point xy coordinate from degree to metres
                  vbdeepak
                  Hi Choilon,


                  Try to use the project method once. Convert the decimal degree to Meters.
                  You mentioned the GCS as inputspatial reference, provide map spatial reference as Projected Coordinate System. Then Your decimal degree point will convert into meters.

                  Regards,
                  Deepak.