--- title: GeoTools-简介 date: 2023-11-28 author: ac categries: - GIS tags: - GeoTools --- ### GeoTools-简介 ### 1.简介 GeoTools是一个开源(LGPL) Java代码库,它为地理空间数据的操作提供了符合标准的方法,例如实现地理信息系统。GeoTools库数据结构基于开放地理空间联盟(OGC)规范。 了解GeoTools库是如何构建的,这有助于您找出需要在应用程序中包含哪些jar。 ### 2. GeoTools 库 ![image-20231128145948967](./images/image-20231128145948967.png) GeoTools库形成了一个软件“堆栈”,每个模块都建立在前一个定义的模块之上。 “堆栈”的每一层都是建立在下一层之上的,例如: - 如果要使用`Referencing` ,你需要先使用`gt-api`,`gt-metadata`,`gt-references`,为了确保`EPSG`codes的正确,还需要使用一个插件`gt-epsg-hsql`来定义EPSG。 - 如果要使用`Coverage`,需要使用`gt-api`,`gt-metadata`,`gt-referencing(包含gt-epsg-hsql)`,`gt-main`和`gt-coverage`。为了充分利用Coverage模块,我们使用了一个插件,比如`gt-geotiff`来访问`GeoTIFF`文件。 `Maven`工具能够计算项目中需要的`jar`. 下面是各个模块的作用: | Module | Purpose | | :--------------- | :----------------------------------------------------------- | | `gt-render` | Map API, with Java2D rendering engine for mapping. | | `gt-jdbc` | Implements for accessing spatial database | | `gt-xml` | Implements of common spatial XML formats | | `gt-cql` | Implements of Common Query Language for filters | | `gt-coverage` | Implementation for accessing raster information | | `gt-main` | Data API, with default implementations of filter, feature, etc… | | `gt-referencing` | Implementation of co-ordinate location and transformation | | `gt-metadata` | Implementation of identification and description | | `gt-api` | Definition of interfaces for common spatial concepts | | `jts` | JTS Topology Suite (external library) implementing Geometry | ### 3. GeoTools 插件 GeoTools提供插件来支持额外的数据格式和不同的坐标参考系统等功能。 | Module | JAR | Plugin | | :--------------- | :------------------ | :------------------------------- | | `gt-render` | | | | `gt-jdbc` | `gt-jdbc-db2` | Geometry in DB2 | | | `gt-jdbc-h2` | Pure Java “H2” database | | | `gt-jdbc-mysql` | Geometry in MySQL | | | `gt-jdbc-oracle` | Oracle SDO Geometry | | | `gt-jdbc-postgis` | PostgreSQL extension PostGIS | | | `gt-jdbc-sqlserver` | SQL Server | | | `gt-jdbc-hana` | SAP HANA | | `gt-xml` | | | | `gt-cql` | | | | `gt-main` | `gt-shape` | Shapefile read/write support | | | `gt-wfs` | WFS read/write support | | `gt-coverage` | `gt-geotiff` | GeoTIFF raster format | | | `gt-arcgrid` | arcgrid format | | | `gt-mif` | MIF format | | | `gt-image` | JPG, PNG, TIFF formats | | `gt-referencing` | `epsg-access` . | Official EPSG database in Access | | | `epsg-hsql` | Pure Java port of EPSG database | | | `epsg-wkt` | Lightweight copy of EPSG codes | | | `epsg-postgresql` | PostgreSQL port of EPSG database | | `gt-metadata` | | | | `gt-api` | | | | `jts` | | | 通常,每个层至少需要一个插件才能让GeoTools做一些事情。 ### 4.GeoTools 扩展 更进一步,在GeoTools库的基础上实现了一些有趣的“扩展”。这些扩展提供了使用核心库的全部功能构建在GeoTools之上的额外功能。 ![image-20231128165232067](./images/image-20231128165232067.png) 这些扩展相互独立,可能在您的应用程序中使用: | JAR | Extension | | :-------------- | :--------------------------------------------------- | | `gt-app-schema` | Map from application schema to complex feature model | | `gt-brewer` | Generation of styles using color brewer | | `gt-complex` | Support for making custom complex feature model | | `gt-graph` | Work with graph and network traversals | | `gt-grid` | Dynamicly generate features from grid definiton | | `gt-transform` | Transform features on the fly | | `gt-wms` | Web Map Server client | | `gt-wmts` | Web Map Tile Server client | | `gt-xsd` | Parsing/Encoding for common OGC schemas | ### 5.XML > 用途:解析和输出sld文件,wfs事务操作 为了支持GeoTools中的XML模块,我们以JAR形式捆绑了几个XML模式(以避免每次需要时都需要从Internet下载它们)。此外,这些jar包含一个由Eclipse Modeling Framework生成的Java数据结构。 | JAR | Schema | | :---------------- | :---------------------------- | | `net.opengis.ows` | open web services schema | | `net.opengis.wfs` | web feature service | | `net.opengis.wps` | web processing service schema | | `net.opengis.wcs` | web coverage service schema | | `net.opengis.wfs` | web feature service schema | | `org.w3.xlink` | XLink schema | XSD解析器通过一系列XSD插件使用这些工具。这些插件指示如何使用Eclipse XSD库解析和编码附加内容,以解析XML模式文档,并提供“绑定”,显示如何解析和编码Java类,如String、Date、URL和Geometry。 | JAR | Bindings | | :-------------- | :-------------------------------- | | `gt-xsd-core` | Basic types defined by XML schema | | `gt-xsd-fes` | filter 2.0 | | `gt-xsd-filter` | filter (used by OGC CAT and WFS) | | `gt-xsd-kml` | keyhole markup language | | `gt-xsd-wfs` | web feature service | | `gt-xsd-wps` | web processing service | | `gt-xsd-gml3` | geographic markup language 3 | | `gt-xsd-gml2` | geographic markup language 2 | | `gt-xsd-ows` | open web services | | `gt-xsd-wcs` | web coverage service | | `gt-xsd-wms` | web map service | | `gt-xsd-sld` | style layer descriptor | #### 参考文章 [1] architecture https://docs.geotools.org/latest/userguide/welcome/architecture.html