How to use custom Coordinate System in ArcGIS Server Client development

Source: Internet
Author: User
Tags silverlight
1. Scenario Description

The application scenario of this article is to query the image data covering the specified city and city through the administrative division of a city. The Administrative Divisions use the xian80 geographic coordinate system, while the image data uses the local plane coordinate system of the city. Therefore, coordinate transformation is required.

The following describes how to perform Coordinate System Conversion in ArcGIS Server development.

2. About the custom Coordinate System

The so-called custom coordinate system in this article refers to the coordinate system that is not included in the coordinate system of ArcGIS. For example, you can use ArcGIS's coordinate system definition tool or the. prj file obtained from other departments.

The custom coordinate system is widely used in China. Generally, each city has its own local coordinate system to obtain the highest measurement accuracy. The conversion parameters (such as the seven and three parameters) between these local coordinate systems and other standard Coordinate Systems (WGS84, xian80, beijing54, or cgcs2000) are generally confidential.

3 Coordinate System in arcgisserver

We know that when developing ArcGIS Server Client applications (such as flex, Silverlight, JavaScript, Android, IOS, and Windows Phone), we all use the rest interface, wkid is usually used in the coordinate system, but this wkid only contains the standard coordinate systems that come with ArcGIS. wkid cannot be used in custom coordinate systems.

In ArcGIS Server 10.0, a new WKT (well-knowntext) is introduced, that is, the coordinate system can be defined through standard text.

In addition, in ArcGIS 10.1, the projection function is enhanced to support custom Earth Reference conversion, so that we can use the custom coordinate system completely in ArcGIS Server development.

4. Sample Data 4.1 custom Coordinate System

In this example, the author fine-tuned the generated custom coordinate system based on the existing coordinate system. Let's call it "XX city independent coordinate system (xx_duli. The coordinate system definition (WKT) is as follows:

Projcs ["xx_duli", geogcs ["gcs_kraovsky_1940", datum ["d_kraovsky_1940", spheroid ["kraovsky_1940", 6378245.0, 298.3], primem ["Greenwich", 0.0], unit ["degree", 0.0174532925199433], projection ["gauss_kruger"], parameter ["false_easting", 50000.0], parameter ["false_northing",-3202855.272], parameter ["central_meridian", 106.419263889], parameter ["scale_factor", 1.0], parameter ["latitude_of_origin", 0.0], Unit ["meter", 1.0]

4.2 customized map benchmark Conversion

In addition, a map reference conversion is defined, which is used to convert between the map reference of the coordinate system (d_craovsky_1940) and the Earth Reference of xian80 (gcs_xian_1980). The conversion definition is as follows:

Geogtran ["example", geogcs ["gcs_xian_1980", datum ["d_xian_1980", spheroid ["xian_1980", 6378140.0, 298.257], primem ["Greenwich", 0.0], unit ["degree", 0.0174532925199433], metadata ["China-Onshore", 73.66, 18.04, 134.85, 53.59, 0.0, 0.0174532925199433, 0.0], geogcs ["gcs_kraovsky_1940", datum ["d_kraovsky_1940", spheroid ["kraovsky_1940", 6378245.0, 298.3], primem ["Greenwich", 0.0], Unit ["degree ", 0.0174532925199433], metadata ["notspecified",-180.0,-90.0, 180.0, 90.0, 0.0, 0.0174532925199433, 0.0], method ["geocentric_translation"], parameter ["x_axis_translation", 0.0], parameter ["y_axis_translation", 0.0], parameter ["z_axis_translation", 0.0]

4.3 create space data

First, use the xian80 coordinate system to create an administrative division element class, then add several division elements, and assign the district/county name attribute.

Then, use the local coordinate system to create an image dataset. In this article, we use a rectangular box to simulate the image range and draw several image footprint elements.
5 key code

Next, we can develop the program. First, let's take a look at the code for Coordinate Conversion (the sample code in this article uses Silverlight ):

            SpatialReference outSR = new SpatialReference("PROJCS[\"xx_duli\",GEOGCS[\"GCS_Krasovsky_1940\",DATUM[\"D_Krasovsky_1940\",SPHEROID[\"Krasovsky_1940\",6378245.0,298.3]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Gauss_Kruger\"],PARAMETER[\"False_Easting\",50000.0],PARAMETER[\"False_Northing\",-3202855.272],PARAMETER[\"Central_Meridian\",106.419263889],PARAMETER[\"Scale_Factor\",1.0],PARAMETER[\"Latitude_Of_Origin\",0.0],UNIT[\"Meter\",1.0]]");            DatumTransform trans = new DatumTransform("GEOGTRAN[\"GCS_Xian_1980_To_Krasovsky_1940\",GEOGCS[\"GCS_Xian_1980\",DATUM[\"D_Xian_1980\",SPHEROID[\"Xian_1980\",6378140.0,298.257]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433],METADATA[\"China - onshore\",73.66,18.04,134.85,53.59,0.0,0.0174532925199433,0.0,3228]],GEOGCS[\"GCS_Krasovsky_1940\",DATUM[\"D_Krasovsky_1940\",SPHEROID[\"Krasovsky_1940\",6378245.0,298.3]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433],METADATA[\"Not specified\",-180.0,-90.0,180.0,90.0,0.0,0.0174532925199433,0.0,1263]],METHOD[\"Geocentric_Translation\"],PARAMETER[\"X_Axis_Translation\",0.0],PARAMETER[\"Y_Axis_Translation\",0.0],PARAMETER[\"Z_Axis_Translation\",0.0]]");            GeometryService projectTask = new GeometryService(geometryUrl);            projectTask.ProjectCompleted += new EventHandler<GraphicsEventArgs>(projectTask_ProjectCompleted);            projectTask.Failed += new EventHandler<TaskFailedEventArgs>(projectTask_Failed);            projectTask.ProjectAsync(e.FeatureSet, outSR, trans, true, null);

Note that in the latest 10.1, The datumtransform parameter is added to the projectasync method. You can specify the in the projection.

Next, we use the returned results (the Administrative Division elements projected into the local coordinate system) to query the space:

            QueryTask spatialQuery = new QueryTask(cqduliUrl);            spatialQuery.Failed += new EventHandler<TaskFailedEventArgs>(spatialQuery_Failed);            spatialQuery.ExecuteCompleted += new EventHandler<QueryEventArgs>(spatialQuery_ExecuteCompleted);            Query query = new Query();            query.ReturnGeometry = true;            query.OutFields.Add("OBJECTID");            query.Geometry = e.Results[0].Geometry;            query.OutSpatialReference = new SpatialReference(4610);            spatialQuery.ExecuteAsync(query);

Note that in the above Code, the input geometry of the Space query, that is, the projection Conversion Result, is already the local plane coordinate system, so that you can query the correct result from the image service. As the final returned results need to be drawn to the map, the output space reference is set to 4610, that is, the xian80 geographic coordinate system.

The code below is nothing more than processing the returned query results, drawing them on the map, and processing the query failure results. I will not go into details. The query results are as follows:

Through the zoning elements of the county in the middle, we can find the sanjing image coverage.

The preceding figure shows how to use a custom coordinate system and a custom in client development. The key is to make good use of WKT, which is provided by the rest SDK, therefore, flex, Silverlight, JavaScript, Android, Windows Phone, or IOS are equally supported.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.