| 1 | /* |
| 2 | * Copyright 2015 Aerospike, Inc. |
| 3 | * |
| 4 | * Portions may be licensed to Aerospike, Inc. under one or more |
| 5 | * contributor license agreements. |
| 6 | * |
| 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you |
| 8 | * may not use this file except in compliance with the License. You |
| 9 | * may obtain a copy of the License at |
| 10 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | * |
| 12 | * Unless required by applicable law or agreed to in writing, software |
| 13 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or |
| 15 | * implied. See the License for the specific language governing |
| 16 | * permissions and limitations under the License. |
| 17 | */ |
| 18 | |
| 19 | #ifndef __geojson_h |
| 20 | #define __geojson_h 1 |
| 21 | |
| 22 | #include <string> |
| 23 | |
| 24 | #include <jansson.h> |
| 25 | |
| 26 | #include <s2cellid.h> |
| 27 | #include <s2region.h> |
| 28 | |
| 29 | namespace GeoJSON { |
| 30 | |
| 31 | class GeometryHandler |
| 32 | { |
| 33 | public: |
| 34 | virtual ~GeometryHandler() {} |
| 35 | |
| 36 | virtual void handle_point(S2CellId const & cellid); |
| 37 | |
| 38 | virtual bool handle_region(S2Region * regionp); |
| 39 | |
| 40 | virtual double earth_radius_meters() { |
| 41 | return 6371000.0; // Wikipedia, mean radius. |
| 42 | } |
| 43 | |
| 44 | void set_json(json_t * i_jsonp) { m_jsonp = i_jsonp; } |
| 45 | |
| 46 | json_t * get_json() { return m_jsonp; } |
| 47 | |
| 48 | private: |
| 49 | json_t * m_jsonp; |
| 50 | }; |
| 51 | |
| 52 | void parse(GeometryHandler & geohand, std::string const & geostr); |
| 53 | |
| 54 | } // end namespace GeoJSON |
| 55 | |
| 56 | #endif // __geojson_h |
| 57 | |