/********************************************************************** * * GEOS - Geometry Engine Open Source * http://geos.osgeo.org * * Copyright (C) 2021 Jared Erickson * * This is free software; you can redistribute and/or modify it under * the terms of the GNU Lesser General Public Licence as published * by the Free Software Foundation. * See the COPYING file for more information. * **********************************************************************/ #pragma once #include #include #include #include #include #include #include "geos/vend/include_nlohmann_json.hpp" // Forward declarations namespace geos { namespace geom { class Coordinate; class GeometryCollection; class Point; class LineString; class LinearRing; class Polygon; class MultiPoint; class MultiLineString; class MultiPolygon; class PrecisionModel; } } namespace geos { namespace io { /** * \class GeoJSONReader * \brief GeoJSON reader class; see also GeoJSONWriter. */ class GEOS_DLL GeoJSONReader { public: /** * \brief Inizialize parser with given GeometryFactory. * * Note that all Geometry objects created by the * parser will contain a pointer to the given factory * so be sure you'll keep the factory alive for the * whole GeoJSONReader and created Geometry life. */ GeoJSONReader(const geom::GeometryFactory& gf); /** * \brief Inizialize parser with default GeometryFactory. * */ GeoJSONReader(); ~GeoJSONReader() = default; /// Parse a GeoJSON string returning a Geometry std::unique_ptr read(const std::string& geoJsonText) const; GeoJSONFeatureCollection readFeatures(const std::string& geoJsonText) const; private: const geom::GeometryFactory& geometryFactory; std::unique_ptr readFeatureForGeometry(const geos_nlohmann::json& j) const; GeoJSONFeature readFeature(const geos_nlohmann::json& j) const; std::map readProperties(const geos_nlohmann::json& p) const; GeoJSONValue readProperty(const geos_nlohmann::json& p) const; std::unique_ptr readFeatureCollectionForGeometry( const geos_nlohmann::json& j) const; GeoJSONFeatureCollection readFeatureCollection( const geos_nlohmann::json& j) const; std::unique_ptr readGeometry( const geos_nlohmann::json& j) const; std::unique_ptr readPoint(const geos_nlohmann::json& j) const; geom::Coordinate readCoordinate(const std::vector& coords) const; std::unique_ptr readLineString( const geos_nlohmann::json& j) const; std::unique_ptr readPolygon( const geos_nlohmann::json& j) const; std::unique_ptr readPolygon( const std::vector>>& c) const; std::unique_ptr readMultiPoint( const geos_nlohmann::json& j) const; std::unique_ptr readMultiLineString( const geos_nlohmann::json& j) const; std::unique_ptr readMultiPolygon( const geos_nlohmann::json& j) const; std::unique_ptr readGeometryCollection( const geos_nlohmann::json& j) const; }; } // namespace io } // namespace geos