|
1 | 1 | # Metadata
|
2 |
| -The `Meta` method provides metadata handling capabilities in GeometryBasics. |
| 2 | +## Meta |
| 3 | +The `Meta` method provides metadata handling capabilities in GeometryBasics. Similarly to remove the metadata and keep only the geometry, use `metafree`, and for vice versa i.e., remove the geometry and keep the metadata use `meta`. |
| 4 | + |
3 | 5 |
|
4 | 6 | ### Syntax
|
5 |
| -```julia |
6 |
| - meta(geometry, meta::NamedTuple) |
7 |
| - meta(geometry; meta...) |
8 |
| -``` |
9 |
| -To remove the metadata and keep only the geometry, use `metafree`, and for vice versa i.e., remove the geometry and keep the metadata use `meta`. |
10 |
| -### Syntax |
11 |
| -```julia |
12 |
| - metafree(meta-geometry) |
13 |
| - meta(meta-geometry) |
14 |
| -``` |
| 7 | +``` |
| 8 | +meta(geometry, meta::NamedTuple) |
| 9 | +meta(geometry; meta...) |
15 | 10 |
|
16 |
| -#### Example: |
17 |
| -```julia |
| 11 | +metafree(meta-geometry) |
| 12 | +meta(meta-geometry) |
| 13 | +``` |
| 14 | +### Example |
| 15 | +```jldoctest |
| 16 | +using GemetryBasics |
18 | 17 | p1 = Point(2.2, 3.6)
|
19 | 18 |
|
20 | 19 | poi = meta(p1, city="Abuja", rainfall=1221.2)
|
@@ -42,52 +41,51 @@ multipoi = MultiPointMeta([p1], city="Abuja", rainfall=1221.2)
|
42 | 41 | ```
|
43 | 42 | In the above example we have also used geometry specific meta methods.
|
44 | 43 |
|
45 |
| -#### Example: |
46 |
| -```julia |
| 44 | +### Example |
| 45 | +```@jldoctest |
47 | 46 | GeometryBasics.MetaType(Polygon)
|
48 | 47 | PolygonMeta
|
49 | 48 |
|
50 | 49 | GeometryBasics.MetaType(Mesh)
|
51 | 50 | MeshMeta
|
52 | 51 | ```
|
53 | 52 | The metageometry objects are infact composed of the original geometry types.
|
54 |
| -```julia |
| 53 | +```@jldoctest |
55 | 54 | GeometryBasics.MetaFree(PolygonMeta)
|
56 | 55 | Polygon
|
57 | 56 |
|
58 | 57 | GeometryBasics.MetaFree(MeshMeta)
|
59 | 58 | Mesh
|
60 |
| - |
61 | 59 | ```
|
62 | 60 | ## MetaT
|
63 |
| -In GeometryBasics we can a have tabular layout for a collection meta-geometries by putting them into a StructArray that extends the Tables.jl API. |
| 61 | +In GeometryBasics we can a have tabular layout for a collection of meta-geometries by putting them into a StructArray that extends the [Tables.jl](https://github.com/JuliaData/Tables.jl) API. |
64 | 62 |
|
65 |
| -In practice it's not necessary for the geometry or metadata types to be consistent. Eg: A .geojson format can have heterogeneous geometries. |
| 63 | +In practice it's not necessary for the geometry or metadata types to be consistent. Eg: A geojson format can have heterogeneous geometries. |
66 | 64 | Hence, such cases require automatic widening of the geometry data types to the most appropriate type. The MetaT method works around the fact that, a collection of geometries and metadata of different types can be represented tabularly whilst widening to the appropriate type.
|
67 | 65 | ### Syntax
|
68 |
| -```julia |
69 |
| - MetaT(geometry, meta::NamedTuple) |
70 |
| - MetaT(geometry; meta...) |
| 66 | +``` |
| 67 | +MetaT(geometry, meta::NamedTuple) |
| 68 | +MetaT(geometry; meta...) |
71 | 69 | ```
|
72 | 70 | Returns a `MetaT` that holds a geometry and its metadata `MetaT` acts the same as `Meta` method.
|
73 | 71 | The difference lies in the fact that it is designed to handle geometries and metadata of different/heterogeneous types.
|
74 | 72 |
|
75 | 73 | eg: While a Point MetaGeometry is a `PointMeta`, the MetaT representation is `MetaT{Point}`
|
76 | 74 |
|
77 |
| -#### Example: |
78 |
| -```julia |
| 75 | +### Example |
| 76 | +```@jldoctest |
79 | 77 | MetaT(Point(1, 2), city = "Mumbai")
|
80 | 78 | MetaT{Point{2,Int64},(:city,),Tuple{String}}([1, 2], (city = "Mumbai",))
|
81 | 79 | ```
|
82 | 80 |
|
83 | 81 | For a tabular representation, an iterable of `MetaT` types can be passed on to a `metatable` method.
|
84 | 82 |
|
85 | 83 | ### Syntax
|
86 |
| -```julia |
87 |
| - meta_table(iter) |
| 84 | +```@jldoctest |
| 85 | +meta_table(iter) |
88 | 86 | ```
|
89 |
| -#### Example: |
90 |
| -```julia |
| 87 | +### Example |
| 88 | +```@jldoctest |
91 | 89 | using DataFrames
|
92 | 90 | # Create an array of 2 linestrings
|
93 | 91 | ls = [LineString([Point(i, i+1), Point(i-1,i+5)]) for i in 1:2]
|
@@ -116,7 +114,6 @@ sa.rainfall
|
116 | 114 | ```
|
117 | 115 |
|
118 | 116 | ### Disadvantages:
|
119 |
| - * The MetaT is pretty generic in terms of geometry types, it's not subtype to geometries. |
120 |
| - eg : A `MetaT{Point, NamedTuple{Names, Types}}` is not subtyped to `AbstractPoint` like a `PointMeta` is. |
| 117 | + * The MetaT is pretty generic in terms of geometry types, it's not subtype to geometries. eg : A `MetaT{Point, NamedTuple{Names, Types}}` is not subtyped to `AbstractPoint` like a `PointMeta` is. |
121 | 118 | * This might cause problems on using `MetaT` with other constructors/methods inside or even outside GeometryBasics methods designed to work with the main `Meta` types.
|
122 | 119 |
|
0 commit comments