1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
use BufReader;
use ;
use File;
use CoordsIter;
use Geometry;
use FeatureReader;
use crateWeightedPoint;
/// Extracts all points from a GeoJSON file for use as origin/destination subpoints.
///
/// This function reads a GeoJSON file and extracts coordinates from all features, optionally
/// weighting each point based on a numeric property. The extracted points can be used with
/// the `Subsample::WeightedPoints` variant for weighted sampling during jittering.
///
/// # Arguments
///
/// * `path` - Path to the GeoJSON file containing point, linestring, or polygon features
/// * `weight_key` - Optional name of a numeric property to use as the relative weight for each
/// point. If `None`, all points are equally weighted (weight = 1.0). Higher weights make
/// points more likely to be selected during sampling.
///
/// # Returns
///
/// Returns a vector of `WeightedPoint` objects, each containing a geographic point and its
/// associated weight.
///
/// # Errors
///
/// Returns an error if:
/// - The file cannot be opened or read
/// - The GeoJSON is malformed
/// - A `weight_key` is specified but a feature doesn't have that property or it's not numeric
///
/// # Examples
///
/// ```rust,no_run
/// use odjitter::scrape_points;
///
/// // Extract points with equal weights
/// let points = scrape_points("road_network.geojson", None)?;
///
/// // Extract points with custom weights based on a property
/// let weighted_points = scrape_points("schools.geojson", Some("capacity".to_string()))?;
/// # Ok::<(), anyhow::Error>(())
/// ```
///
/// # Note
///
/// The returned points are not deduplicated. If the input geometry contains duplicate
/// coordinates, they will appear multiple times in the output, each with their respective weight.