GEOS 3.15.0dev
RandomPointsBuilder.h
1/**********************************************************************
2*
3 * GEOS - Geometry Engine Open Source
4 * http://geos.osgeo.org
5 *
6 * Copyright (C) 2016 Martin Davis
7 *
8 * This is free software; you can redistribute and/or modify it under
9 * the terms of the GNU Lesser General Public Licence as published
10 * by the Free Software Foundation.
11 * See the COPYING file for more information.
12 *
13 **********************************************************************
14 *
15 * Last port: shape/random/RandomPointsBuilder.java e92970e3c0
16 *
17 **********************************************************************/
18
19#pragma once
20
21#include <geos/export.h>
22
23#include <geos/algorithm/locate/PointOnGeometryLocator.h>
24#include <geos/geom/Envelope.h>
25#include <geos/geom/Geometry.h>
26#include <geos/shape/GeometricShapeBuilder.h>
27
28#include <memory>
29#include <random>
30
31namespace geos::shape::random {
32
40class GEOS_DLL RandomPointsBuilder : public GeometricShapeBuilder {
41public:
42
44
45 using GeometricShapeBuilder::setExtent;
46
47 void setExtent(const geom::Geometry& mask);
48
49 std::unique_ptr<geom::Geometry> getGeometry() override;
50
51protected:
52
53 bool isInExtent(const geom::CoordinateXY& p) const;
54
55 geom::CoordinateXY createRandomCoord(const geom::Envelope& env);
56
57 std::unique_ptr<geom::Geometry> maskPoly;
58private:
59 std::unique_ptr<algorithm::locate::PointOnGeometryLocator> extentLocator;
60 std::random_device rd;
61 std::mt19937 rng;
62 std::uniform_real_distribution<double> dist{0, 1};
63};
64
65}
An Envelope defines a rectangulare region of the 2D coordinate plane.
Definition Envelope.h:59
Supplies a set of utility methods for building Geometry objects from CoordinateSequence or other Geom...
Definition GeometryFactory.h:71
Basic implementation of Geometry, constructed and destructed by GeometryFactory.
Definition Geometry.h:196
Definition RandomPointsBuilder.h:40