ici-be/ici-tools
Composer 安装命令:
composer require ici-be/ici-tools
包简介
Spatial PHP tools. The WfsLayer class helps create requests on a WFS layer using a PHP object. Web Feature Service (WFS) is a standard of the Open Geospatial Consortium.
README 文档
README
ici-tools is a PHP geo-related library, providing spatial tools. Contributions welcome :)
Features
- WfsLayer helps create requests on a WFS layer using a PHP object. Web Feature Service (WFS) is a standard of the Open Geospatial Consortium.
Installation
composer require ici-be/ici-tools
WfsLayer
Query a WFS layer with PHP (Geoserver / ArcGIS).
A. Typical usage with method chaining
- Example with a BRIC.brussels layer containing the 19 municipalities of the Brussels-Capital Region in Belgium
<?php use ici\ici_tools\WfsLayer; // Construct layer with base path and layer name $wfs = new WfsLayer('https://geoservices-urbis.irisnet.be/geoserver/wfs', 'UrbisAdm:Mu'); // Limit to municipalities greather than 10 km², order by name DESC, keep only the name in French $wfs->setCqlFilter('AREA(GEOM)>10000000')->setSortBy('MU_NAME_FRE', 'DESC')->setPropertyName('MU_NAME_FRE'); // Dump properties as an array var_dump($wfs->getPropertiesArray()); /* array:4 [▼ 0 => [ "MU_NAME_FRE" => "Watermael-Boitsfort" ] 1 => [ "MU_NAME_FRE" => "Uccle" ] 2 => [ "MU_NAME_FRE" => "Bruxelles" ] 3 => [ "MU_NAME_FRE" => "Anderlecht" ] ] */
B. Available methods
- All setters can be chained and have public getters
setVersion(string $version); // Change WFS version (default: "2.0.0") setPropertyName(string $property_name); // To restrict requested attributes. You can specify a single attribute, or multiple attributes separated by commas. setCqlFilter(string $cql_filter); // See the CQL_FILTER documentation: https://docs.geoserver.org/stable/en/user/tutorials/cql/cql_tutorial.html setOutputSrs(int $output_srs); // Spatial reprojection using another SRS (ex: 4326 for EPSG:4326) setMethod(string $method = 'POST'); // use GET or POST method (POST is used by default but is not always available) setOutputFormat(string $output_format = 'json'); // The class needs a json/geojson format to work. If the default doesn't work, check with a getCapabilities Query. Sometimes it's called "GEOJSON" for example. setStartIndex(int $start_index); // To start display results after x elements (for pagination) setCount(int $count); // To limit the number of features returned setSortBy(string $sort_by, string $order = 'ASC'); // To sort the returned selection based on an attribute value
- Other getters
getHits(); // Return only the number of results getResults(); // Return the json data as a PHP object getPropertiesArray(); // Return the rows and their properties in a PHP array getQueryUrl(); // Return the query as a URL with GET parameters
C. More examples
<?php use ici\ici_tools\WfsLayer; // Construct layer with base path and layer name $wfs = new WfsLayer('https://geoservices-urbis.irisnet.be/geoserver/wfs', 'UrbisAdm:Mu'); // 1. Return everything as an object var_dump($wfs->getResults()); /* +"type": "FeatureCollection" +"features": array:19 [▶] +"totalFeatures": 19 +"numberMatched": 19 +"numberReturned": 19 +"timeStamp": "2020-12-21T19:27:58.952Z" +"crs": {#600 ▶} +"bbox": array:4 [▶] */ // 2. Limit query to municipalities beginning with "Woluwe" in French $wfs->setCqlFilter("MU_NAME_FRE LIKE 'Woluwe%'"); // 3. Limit retrieved attributes to MU_NAME_FRE, MU_NAME_DUT and GEOM (municipalities names in French and Dutch, and the geometry) $wfs->setPropertyName('MU_NAME_FRE,MU_NAME_DUT,GEOM'); // 4. Return the url of the generated query $wfs->getQueryUrl(); // https://geoservices-urbis.irisnet.be/geoserver/wfs?service=WFS&version=2.0.0&request=GetFeature&typeName=UrbisAdm%3AMu&outputFormat=json&resultType=results&propertyname=MU_NAME_FRE%2CMU_NAME_DUT%2CGEOM&cql_filter=MU_NAME_FRE+LIKE+%27Woluwe%25%27 // 5. Return the rows and their properties in an array $wfs->getPropertiesArray() /* array:2 [▼ 0 => array:3 [▼ "MU_NAME_DUT" => "Sint-Pieters-Woluwe" "MU_NAME_FRE" => "Woluwe-Saint-Pierre" "MU_ID" => 8900 ] 1 => array:3 [▼ "MU_NAME_DUT" => "Sint-Lambrechts-Woluwe" "MU_NAME_FRE" => "Woluwe-Saint-Lambert" "MU_ID" => 8800 ] ] */
ici-be/ici-tools 适用场景与选型建议
ici-be/ici-tools 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.99k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2020 年 12 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「projection」 「geospatial」 「ArcGIS」 「geoserver」 「WFS」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 ici-be/ici-tools 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 ici-be/ici-tools 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 ici-be/ici-tools 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
QuadTree implementation in PHP
ArcGIS Online OAuth2 Provider for Laravel Socialite
GeoJSON implementation for PHP
PHP FFI bindings for Uber's H3 hexagonal hierarchical geospatial indexing system
Read-model components for Daikon-CQRS projects.
A Laravel package to parse KML and KMZ files
统计信息
- 总下载量: 4.99k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 24
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-12-05