流
🌐 Streams
流不是生成中间表示,而是通过函数调用转换几何以最小化开销。流必须实现多个方法来接收输入几何。流本质上是有状态的;一个点的含义取决于该点是否在一条线内,同样,一条线通过一个多边形来区分是否为环。尽管名称是“流”,这些方法调用目前是同步的。
🌐 Rather than materializing intermediate representations, streams transform geometry through function calls to minimize overhead. Streams must implement several methods to receive input geometry. Streams are inherently stateful; the meaning of a point depends on whether the point is inside of a line, and likewise a line is distinguished from a ring by a polygon. Despite the name “stream”, these method calls are currently synchronous.
geoStream(对象, 流)
🌐 geoStream(object, stream)
来源 · 将指定的 GeoJSON 对象 流式传输到指定的 投影 流。虽然输入既支持要素也支持几何对象,但流接口仅描述几何,因此额外的要素属性对流不可见。
stream.point(x, y, z)
表示具有指定坐标 x 和 y(可选 z)的点。坐标系统未指定并且依赖于实现;例如,投影流 需要以度为单位的球面坐标作为输入。在多边形或线的上下文之外,点表示一个点几何对象(Point 或 MultiPoint)。在一条线或多边形环中,点表示一个控制点。
🌐 Indicates a point with the specified coordinates x and y (and optionally z). The coordinate system is unspecified and implementation-dependent; for example, projection streams require spherical coordinates in degrees as input. Outside the context of a polygon or line, a point indicates a point geometry object (Point or MultiPoint). Within a line or polygon ring, the point indicates a control point.
stream.lineStart()
表示一条线或环的开始。在多边形内,表示一个环的开始。多边形的第一个环是外环,通常为顺时针方向。任何后续的环表示多边形中的孔,通常为逆时针方向。
🌐 Indicates the start of a line or ring. Within a polygon, indicates the start of a ring. The first ring of a polygon is the exterior ring, and is typically clockwise. Any subsequent rings indicate holes in the polygon, and are typically counterclockwise.
stream.lineEnd()
表示一条线或环的结束。在多边形内,表示环的结束。与 GeoJSON 不同,环的冗余闭合坐标 不会 通过 点 表示,而是通过多边形内的 lineEnd 来暗示。因此,给定的多边形输入:
🌐 Indicates the end of a line or ring. Within a polygon, indicates the end of a ring. Unlike GeoJSON, the redundant closing coordinate of a ring is not indicated via point, and instead is implied via lineEnd within a polygon. Thus, the given polygon input:
{
"type": "Polygon",
"coordinates": [[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]
}将在流中产生以下一系列方法调用:
🌐 Will produce the following series of method calls on the stream:
stream.polygonStart();
stream.lineStart();
stream.point(0, 0);
stream.point(0, 1);
stream.point(1, 1);
stream.point(1, 0);
stream.lineEnd();
stream.polygonEnd();stream.polygonStart()
表示多边形的开始。多边形的第一条线表示外环,任何后续的线表示内部孔洞。
🌐 Indicates the start of a polygon. The first line of a polygon indicates the exterior ring, and any subsequent lines indicate interior holes.
stream.polygonEnd()
表示多边形的终点。
🌐 Indicates the end of a polygon.
stream.sphere()
表示球体(地球;以 ⟨0,0,0⟩ 为中心的单位球体)。
🌐 Indicates the sphere (the globe; the unit sphere centered at ⟨0,0,0⟩).