meface/docs/article/gis/openlayers/51olgeometrymodel.md

46 lines
2.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
title: ol中的空间数据组织
date: 2020-10-10
author: ac
tags:
- OpenLayers
categories:
- GIS
---
### `Openlayers`中的空间数据组织
`Openlayers`采用面向对象的方式进行开发,空间数据中的点、线、面三类矢量数据都有与之相应的`js`类。在`Openlayers` 5中矢量数据以Geometry抽象类作为基类派生出点、线、面和多点、多线、多面以及集合类还有线性环等类。`GeometryCollection`则为Geometry对象的集合。
<img src="./images/image5738429.png" alt="image5738429" style="zoom: 80%;" />
<div style='text-align:center'>矢量数据组织结构</div>
上图为Geometry基类及其子类的继承关系有点类似于OGC的另一规范GML提供的几何要素。其中LinearRing是一段封闭的线状路径至少4个坐标点三个坐标可以确定LinearRing第四个坐标用于闭合与第一个坐标相同且只能用作定义面要素时描述面的外边界或内边界时使用。
可以简单分为:
- 基础的几何体(`primitive`)`Point`、`LineString`、`Polygon`、`LinearRing`、`Circle`
- 单一集合体(`aggregate`)`MultiPoint`、`MultiLineString`、`MultiPolygon`
- 复合集合体(`complex`)`GeometryCollection`
在实现细节上,采用命名空间进行模块化开发,矢量数据的几何对象在`ol.geom`命名空间下。
- `ol/geom/Geometry`(抽象类)
- `ol/geom/GeometryCollection`
- `ol/geom/SimpleGeometry`(抽象类)
- `ol/geom/Point `
- `ol/geom/MultiPoint`
- `ol/geom/LineString`
- `ol/geom/MultiLineString`
- `ol/geom/LinearRing`只能用来构建Polygon
- `ol/geom/Polygon`
- `ol/geom/MultiPolygon`
- `ol/geom/Circle`
> 作用:作为要素`feature`的几何属性,描述要素的外形特征。
`Openlayer`在加载和解析(`ol.format`矢量数据的时候会创建数据中的几何对象通过Feature子类`ol.Feature`)组织为要素或使用`ol.Collection`子类组织为要素集合,作为矢量图层数据源。