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

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.

主站蜘蛛池模板: 庆阳市| 德保县| 密山市| 日土县| 阿图什市| 吐鲁番市| 平山县| 北京市| 固阳县| 东城区| 石景山区| 新源县| 墨玉县| 云安县| 宜春市| 吉木乃县| 五华县| 松江区| 金塔县| 鲁山县| 曲阳县| 扶风县| 龙岩市| 满城县| 博爱县| 贡嘎县| 建平县| 渝中区| 辛集市| 集安市| 肇东市| 小金县| 灵宝市| 黄梅县| 剑阁县| 涞源县| 南陵县| 文成县| 丹棱县| 两当县| 隆林|