[installation] Change to nightly
This commit is contained in:
@ -26,6 +26,7 @@
|
||||
#include <seiscomp/geo/boundingbox.h>
|
||||
|
||||
#include <map>
|
||||
#include <ostream>
|
||||
|
||||
namespace Seiscomp {
|
||||
namespace Geo {
|
||||
@ -39,27 +40,32 @@ struct SC_SYSTEM_CORE_API Category {
|
||||
unsigned int id;
|
||||
std::string name;
|
||||
std::string localName;
|
||||
const Category* parent;
|
||||
const Category *parent;
|
||||
std::string dataDir;
|
||||
|
||||
Category(unsigned int id, std::string name = "",
|
||||
const Category* parent = nullptr) :
|
||||
id(id), name(name), parent(parent) {}
|
||||
const Category *parent = nullptr) :
|
||||
id(id), name(std::move(name)), parent(parent) {}
|
||||
};
|
||||
|
||||
|
||||
class SC_SYSTEM_CORE_API GeoFeature : public Core::BaseObject {
|
||||
public:
|
||||
typedef std::map<std::string, std::string> Attributes;
|
||||
using GeoCoordinates = std::vector<GeoCoordinate>;
|
||||
using SubFeatures = std::vector<size_t>;
|
||||
using Attributes = std::map<std::string, std::string>;
|
||||
|
||||
GeoFeature(const Category* category = nullptr, unsigned int rank = 1);
|
||||
GeoFeature(const std::string& name, const Category* category,
|
||||
GeoFeature(const Category *category = nullptr, unsigned int rank = 1);
|
||||
GeoFeature(std::string name, const Category *category,
|
||||
unsigned int rank);
|
||||
GeoFeature(const std::string& name, const Category* category,
|
||||
unsigned int rank, const Attributes& attributes);
|
||||
GeoFeature(std::string name, const Category *category,
|
||||
unsigned int rank, Attributes attributes);
|
||||
virtual ~GeoFeature();
|
||||
|
||||
public:
|
||||
bool operator==(const GeoFeature &other) const;
|
||||
bool operator!=(const GeoFeature &other) const;
|
||||
|
||||
void setName(const std::string &name) { _name = name; }
|
||||
const std::string &name() const { return _name; }
|
||||
|
||||
@ -100,9 +106,9 @@ class SC_SYSTEM_CORE_API GeoFeature : public Core::BaseObject {
|
||||
void setUserData(void*);
|
||||
void *userData() const;
|
||||
|
||||
const std::vector<GeoCoordinate> &vertices() const { return _vertices; }
|
||||
const GeoCoordinates &vertices() const { return _vertices; }
|
||||
const GeoBoundingBox &bbox() const { return _bbox; }
|
||||
const std::vector<size_t> &subFeatures() const { return _subFeatures; }
|
||||
const SubFeatures &subFeatures() const { return _subFeatures; }
|
||||
|
||||
bool contains(const GeoCoordinate &v) const;
|
||||
|
||||
@ -115,26 +121,27 @@ class SC_SYSTEM_CORE_API GeoFeature : public Core::BaseObject {
|
||||
static double area(const GeoCoordinate *polygon, size_t sides) __attribute__((deprecated));
|
||||
|
||||
private:
|
||||
typedef std::vector<GeoCoordinate> GeoCoordinates;
|
||||
|
||||
std::string _name;
|
||||
const Category *_category;
|
||||
void *_userData;
|
||||
unsigned int _rank;
|
||||
const Category *_category{nullptr};
|
||||
void *_userData{nullptr};
|
||||
unsigned int _rank{1};
|
||||
GeoFeature::Attributes _attributes;
|
||||
|
||||
GeoCoordinates _vertices;
|
||||
bool _closedPolygon;
|
||||
bool _closedPolygon{false};
|
||||
GeoBoundingBox _bbox;
|
||||
|
||||
/** Index of verticies marking the start of a sub feature.
|
||||
* E.g. if the GeoFeature defines a main area and a group of
|
||||
* islands this vector would contain the indices of the start
|
||||
* point of each island */
|
||||
std::vector<size_t> _subFeatures;
|
||||
SubFeatures _subFeatures;
|
||||
};
|
||||
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const GeoFeature &gf);
|
||||
|
||||
|
||||
inline void *GeoFeature::userData() const {
|
||||
return _userData;
|
||||
}
|
||||
|
||||
@ -25,12 +25,13 @@
|
||||
#include <seiscomp/core.h>
|
||||
#include <seiscomp/geo/feature.h>
|
||||
|
||||
#include <vector>
|
||||
#include <boost/filesystem/path.hpp>
|
||||
|
||||
#include <ostream>
|
||||
#include <vector>
|
||||
|
||||
namespace Seiscomp {
|
||||
namespace Geo {
|
||||
|
||||
namespace Seiscomp::Geo {
|
||||
|
||||
|
||||
class GeoFeatureSet;
|
||||
@ -54,13 +55,16 @@ class SC_SYSTEM_CORE_API GeoFeatureSetObserver {
|
||||
class SC_SYSTEM_CORE_API GeoFeatureSet : public Core::BaseObject {
|
||||
public:
|
||||
/** Default constructor */
|
||||
GeoFeatureSet();
|
||||
GeoFeatureSet() = default;
|
||||
/** Destructor */
|
||||
virtual ~GeoFeatureSet();
|
||||
|
||||
/** Copy operator, intentionally left undefined */
|
||||
GeoFeatureSet & operator=(const GeoFeatureSet &);
|
||||
|
||||
using Features = std::vector<GeoFeature*>;
|
||||
using Categories = std::vector<Category*>;
|
||||
|
||||
|
||||
public:
|
||||
bool registerObserver(GeoFeatureSetObserver*);
|
||||
@ -68,6 +72,11 @@ class SC_SYSTEM_CORE_API GeoFeatureSet : public Core::BaseObject {
|
||||
|
||||
|
||||
public:
|
||||
/** Comparison operator */
|
||||
bool operator==(const GeoFeatureSet &other) const;
|
||||
/** Comparison operator */
|
||||
bool operator!=(const GeoFeatureSet &other) const;
|
||||
|
||||
/**
|
||||
* Removes and destructs all elements from the _features and
|
||||
* _categories vectors
|
||||
@ -124,10 +133,10 @@ class SC_SYSTEM_CORE_API GeoFeatureSet : public Core::BaseObject {
|
||||
bool addFeature(GeoFeature *feature);
|
||||
|
||||
/** Returns reference to GeoFeature vector */
|
||||
const std::vector<GeoFeature*> &features() const { return _features; };
|
||||
const Features &features() const { return _features; };
|
||||
|
||||
/** Returns reference to Category vector */
|
||||
const std::vector<Category*> &categories() const { return _categories; };
|
||||
const Categories &categories() const { return _categories; };
|
||||
|
||||
|
||||
private:
|
||||
@ -143,8 +152,8 @@ class SC_SYSTEM_CORE_API GeoFeatureSet : public Core::BaseObject {
|
||||
Category *category);
|
||||
|
||||
/** Prints the number of polygons read */
|
||||
const std::string initStatus(const std::string &directory,
|
||||
unsigned int fileCount) const;
|
||||
std::string initStatus(const std::string &directory,
|
||||
unsigned int fileCount) const;
|
||||
|
||||
/** Compares two GeoFeatures by their rank */
|
||||
static bool compareByRank(const GeoFeature* gf1, const GeoFeature* gf2);
|
||||
@ -160,15 +169,17 @@ class SC_SYSTEM_CORE_API GeoFeatureSet : public Core::BaseObject {
|
||||
|
||||
private:
|
||||
/** Vector of GeoFeatures */
|
||||
std::vector<GeoFeature*> _features;
|
||||
Features _features;
|
||||
|
||||
/** Vector of Categories */
|
||||
std::vector<Category*> _categories;
|
||||
Categories _categories;
|
||||
|
||||
typedef std::vector<GeoFeatureSetObserver*> ObserverList;
|
||||
ObserverList _observers;
|
||||
};
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const GeoFeatureSet &gfs);
|
||||
|
||||
|
||||
class SC_SYSTEM_CORE_API GeoFeatureSetSingleton {
|
||||
public:
|
||||
@ -184,8 +195,7 @@ class SC_SYSTEM_CORE_API GeoFeatureSetSingleton {
|
||||
};
|
||||
|
||||
|
||||
} // of ns Geo
|
||||
} // of ns Seiscomp
|
||||
} // ns Seiscomp::Geo
|
||||
|
||||
|
||||
#endif // SEISCOMP_GEO_FEATURESET_H__
|
||||
|
||||
80
include/seiscomp/geo/formats/fep.h
Normal file
80
include/seiscomp/geo/formats/fep.h
Normal file
@ -0,0 +1,80 @@
|
||||
/***************************************************************************
|
||||
* Copyright (C) gempa GmbH *
|
||||
* All rights reserved. *
|
||||
* Contact: gempa GmbH (seiscomp-dev@gempa.de) *
|
||||
* *
|
||||
* GNU Affero General Public License Usage *
|
||||
* This file may be used under the terms of the GNU Affero *
|
||||
* Public License version 3.0 as published by the Free Software Foundation *
|
||||
* and appearing in the file LICENSE included in the packaging of this *
|
||||
* file. Please review the following information to ensure the GNU Affero *
|
||||
* Public License version 3.0 requirements will be met: *
|
||||
* https://www.gnu.org/licenses/agpl-3.0.html. *
|
||||
* *
|
||||
* Other Usage *
|
||||
* Alternatively, this file may be used in accordance with the terms and *
|
||||
* conditions contained in a signed written agreement between you and *
|
||||
* gempa GmbH. *
|
||||
***************************************************************************/
|
||||
|
||||
|
||||
#ifndef SEISCOMP_GEO_FORMATS_FEP_H
|
||||
#define SEISCOMP_GEO_FORMATS_FEP_H
|
||||
|
||||
|
||||
#include <seiscomp/geo/featureset.h>
|
||||
|
||||
|
||||
namespace Seiscomp::Geo {
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reads a FEP plus file and adds found features to the feature set.
|
||||
* In case of an error an exception is thrown. Only closed polygons
|
||||
* are supported.
|
||||
*
|
||||
* Example:
|
||||
* 13.0 52.0
|
||||
* 13.0 53.0
|
||||
* 14.0 53.0
|
||||
* 14.0 52.0
|
||||
* 99.0 99.0 4
|
||||
* L Germany
|
||||
*
|
||||
* Format definition:
|
||||
* longtitude1 latitude1
|
||||
* ...
|
||||
* longtitudeN latitudeN
|
||||
* 99.0 99.0 VERTEX_COUNT
|
||||
* L POLYGON_NAME
|
||||
*
|
||||
* A polygon starts with a number vertex lines. A vetex contains 2 floats,
|
||||
* longitude and latitude, and may be followed by a comment which must not
|
||||
* start on a digit.
|
||||
*
|
||||
* A polygon is required to declare at least 3 vertices. If the last vertex
|
||||
* matches the first one a minimum of 4 vertices are required.
|
||||
*
|
||||
* After the vertex definition an option vertex count line may follow
|
||||
* expressed with a longitude and latitude value of 99 followed by the
|
||||
* vertex count. If the count does not match the vertices read a warning
|
||||
* is reported.
|
||||
*
|
||||
* A polygon is finalized by an mandatory L line defining the polygon name.
|
||||
*
|
||||
* All lines read are stipped first. Empty lines and lines starting on '#'
|
||||
* are ignored.
|
||||
*
|
||||
* @param featureSet The target feature that will hold the read features
|
||||
* @param filename The path to the GeoJSON file
|
||||
* @param category An optional category attached to all read features
|
||||
* @return The number of features read
|
||||
*/
|
||||
size_t readFEP(GeoFeatureSet &featureSet, const std::string &path,
|
||||
const Category *category = nullptr);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
@ -22,18 +22,20 @@
|
||||
#define SEISCOMP_GEO_FORMATS_GEOJSON_H
|
||||
|
||||
|
||||
#include <seiscomp/geo/feature.h>
|
||||
#include <seiscomp/geo/featureset.h>
|
||||
|
||||
#include <ostream>
|
||||
|
||||
namespace Seiscomp {
|
||||
namespace Geo {
|
||||
|
||||
namespace Seiscomp::Geo {
|
||||
|
||||
|
||||
/**
|
||||
* @brief Reads a GeoJSON file and adds found features to the feature set.
|
||||
* In case of an error an exception is thrown.
|
||||
* @param featureSet The target feature that will hold the read features
|
||||
* @param filename The path to the GeoJSON file
|
||||
* @param path The path to the GeoJSON file
|
||||
* @param category An optional category attached to all read features
|
||||
* @return The number of features read
|
||||
*/
|
||||
@ -41,7 +43,46 @@ size_t readGeoJSON(GeoFeatureSet &featureSet, const std::string &path,
|
||||
const Category *category = nullptr);
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
* @brief Write a GeoFeature to a ostream.
|
||||
* @param os The ostream to write to
|
||||
* @param feature The feature to serialize
|
||||
* @param indent Indentation depth for pretty printing. Disabled if less than 0.
|
||||
* @return true if the feature was written
|
||||
*/
|
||||
bool writeGeoJSON(std::ostream &os, const GeoFeature &feature, int indent = -1);
|
||||
|
||||
/**
|
||||
* @brief Write a GeoFeature to a GeoJSON file.
|
||||
* @param path The path to the GeoJSON file
|
||||
* @param feature The feature to serialize
|
||||
* @param indent Indentation depth for pretty printing. Disabled if less than 0.
|
||||
* @return true if the feature was written
|
||||
*/
|
||||
bool writeGeoJSON(const std::string &path, const GeoFeature &feature,
|
||||
int indent = -1);
|
||||
|
||||
/**
|
||||
* @brief Write a GeoFeature vector to a ostream.
|
||||
* @param os The ostream to write to
|
||||
* @param gfs The geo feature vector to serialize
|
||||
* @param indent Indentation depth for pretty printing. Disabled if less than 0.
|
||||
* @return Number of feature written
|
||||
*/
|
||||
size_t writeGeoJSON(std::ostream &os, const GeoFeatureSet::Features &gfs,
|
||||
int indent = -1);
|
||||
|
||||
/**
|
||||
* @brief Write a GeoFeature vector to a GeoJSON file.
|
||||
* @param path The path to the GeoJSON file
|
||||
* @param gfs The geo feature vector to serialize
|
||||
* @param indent Indentation depth for pretty printing. Disabled if less than 0.
|
||||
* contained in gfs are appended to the GeoJSON file. When appending the
|
||||
* @return Number of feature written
|
||||
*/
|
||||
size_t writeGeoJSON(const std::string &path, const GeoFeatureSet::Features &gfs,
|
||||
int indent = -1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user