官术网_书友最值得收藏!

Introducing geometry objects

Geometry objects are a collection of coordinates that describe where something is in the world. They give shape to the data we're looking for. They can be used for displaying graphics on a map, or to provide spatial data for queries, or even for geoprocessing services. Geometry objects come in five basic types: point, line, polygon, extent, and multipoint. Any shapes are built on these basic types. Let's take a closer look.

Point

In the ArcGIS API for JavaScript, a point is the simplest geometry object. It contains the x and y coordinates of the point, as well as the point's spatial reference. A point can be constructed with x and y coordinates, plus a spatial reference. It can also be defined by longitude and latitude.

Polyline

A polyline geometry is a collection of one or more arrays of point coordinates. Each array of point coordinates is called a path, and would look like a line when drawn out. Multiple paths can be stored in the same geometry, giving the appearance of multiple lines. The individual point coordinates are stored as array of x and y values.

Polygon

Polygons are made up of one or more arrays of points that loop back on themselves. Each array of points is referred to as a ring, and the first and last point in a ring must have the same coordinate. Polygons made up of more than one ring are referred to as multipart-polygons.

Among the many properties and methods that control the polygon's shape are two useful methods: .getCentroid() and .contains(),.getCentroid() returns a point that is roughly in the middle of the polygon. The formula used to calculate the centroid's position can be found on the Wikipedia page for centroids: (http://en.wikipedia.org/wiki/Centroid#Centroid_of_polygon). The .contains() method takes a point as an input, and returns a boolean value based on whether the point is inside the polygon or not.

Extent

An extent is a rectangular polygon, which only uses four numbers to describe its shape. The extent is described by its minimum x value (xmin), maximum x value (xmax), minimum y value (ymin), and maximum y value (ymax). When viewed on a map, extents typically look like a box.

Extents are used by many different parts of the API. All other geometry objects other than points have a getExtent() method, which is used to collect the bounding box of the geometry. You can zoom to a specific location on a map by setting the map's extent. Extents are also used to define an area of interest when identifying things on a map.

Multipoint

Sometimes you need a cluster of points to show on the map. For that, the multipoint is your answer. You can add and remove points using the addPoint() and removePoint() methods. You can also get the general area the points cover with the getExtent() method. They're useful for collecting random points in an area, and for selecting unconnected features on a map.

Geometry spatial reference

Besides coordinates of a geometry's location, the geometry object also packs information on the object's spatial reference. The spatial reference describes the mathematical models used to describe the Earth within the mapped region. Instead of containing all those formulas and constants, the spatial reference stores a reference to those formulas through either a well-known ID (WKID), or a well-known text (WKT).

Spatial Reference plays a crucial role when displaying data on a map. Tiled map service layers must have the same spatial reference as the map, in order to be displayed. Dynamic map service layers must be reprojected, adding to the server time and workload. Graphics also need to be in the same spatial reference as the map to appear in the correct places on the map.

主站蜘蛛池模板: 海宁市| 墨竹工卡县| 绵阳市| 淳安县| 九江市| 馆陶县| 晋宁县| 全州县| 娄烦县| 平阴县| 磴口县| 新郑市| 静海县| 青田县| 新余市| 临颍县| 海宁市| 双鸭山市| 房产| 南丰县| 宣化县| 台北县| 天柱县| 南陵县| 永泰县| 阳信县| 彩票| 抚顺市| 泾阳县| 舞阳县| 鄢陵县| 安丘市| 沂源县| 西华县| 南召县| 建德市| 莲花县| 永丰县| 三明市| 黎平县| 岑巩县|