Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 112 lines (84 sloc) 3.269 kb
a946ec9 @filonenko-mikhail Create docs. Rename line-primitive to linear-ring
authored
1 cl-ewkb is a geospatial library, based on cl-wkb, that implements the OGC Well-Known Binary geographic geometry data model with PostGIS 3d, 4d extensions, and provides WKB and EWKB encoding and decoding functionality. cl-wkb author is J.P. Larocue.
f3e3775 @filonenko-mikhail Initial commit
authored
2
a946ec9 @filonenko-mikhail Create docs. Rename line-primitive to linear-ring
authored
3 Depends on:
f48fe3c @filonenko-mikhail fix readme
authored
4 ieee-floats
f3e3775 @filonenko-mikhail Initial commit
authored
5 flexi-streams
6
a946ec9 @filonenko-mikhail Create docs. Rename line-primitive to linear-ring
authored
7 PostGIS extension WKB described in postgis-1.5/doc/ZMSgeoms.txt
8 All extensions are supported: 3dz, 3dm, 4d, embedded SRID.
9
10 Exported structs
11
12 point-primitive x y
13 pointz-primitive x y z
14 pointm-primitive x y m
15 pointzm-primitive x y z m
4ff3f54 @filonenko-mikhail mini change in readme
authored
16 point-primtive structs contain coordinates (2d, 3d, 4d)
a946ec9 @filonenko-mikhail Create docs. Rename line-primitive to linear-ring
authored
17
18
f48fe3c @filonenko-mikhail fix readme
authored
19 linear-ring points-primitive
4ff3f54 @filonenko-mikhail mini change in readme
authored
20 linear-ring struct contains array of point-primitive
21
f48fe3c @filonenko-mikhail fix readme
authored
22 geometry type srid
23 geometry parent struct for other types and also contains "GEOMETRYCOLLECTION"
f3e3775 @filonenko-mikhail Initial commit
authored
24
f48fe3c @filonenko-mikhail fix readme
authored
25 point type srid point-primitive
26 line-string type srid points-primitive
27 polygon type srid linear-rings
28 multi-point type srid points
29 multi-line-string type srid line-strings
30 multi-polygon type srid polygons
31 geometry-collection type srid geometries
f3e3775 @filonenko-mikhail Initial commit
authored
32
a946ec9 @filonenko-mikhail Create docs. Rename line-primitive to linear-ring
authored
33 Exported functions
f3e3775 @filonenko-mikhail Initial commit
authored
34
35 (decode octets)
36 Decode from wkb sequence
37 (decode-from stream)
38 Decode from wkb stream
39
40 Functions for encoding:
41
42 (encode object endianness)
43 Encode object to vector
44
45 (encode-to object stream endianness)
a946ec9 @filonenko-mikhail Create docs. Rename line-primitive to linear-ring
authored
46 Encode object to stream with endianness
47
48 Example:
49
50 Getting data from postgresql and decode it:
51
52 (decode (caar (query (:select (:ST_AsEWKB "SRID=4326;LINESTRING(0 0 1 2, 1 1 2 3, 2 2 3 4)")))))
53
54 Result:
55
56 #(CL-EWKB::GISGEOMETRY 3758096386 4326
57 #(CL-EWKB::LINEAR-RING
58 #(#(CL-EWKB::POINT-PRIMITIVE 0.0d0 0.0d0 CL-EWKB::POINTZ-PRIMITIVE 1.0d0
59 CL-EWKB::POINTZM-PRIMITIVE 2.0d0)
60 #(CL-EWKB::POINT-PRIMITIVE 1.0d0 1.0d0 CL-EWKB::POINTZ-PRIMITIVE 2.0d0
61 CL-EWKB::POINTZM-PRIMITIVE 3.0d0)
62 #(CL-EWKB::POINT-PRIMITIVE 2.0d0 2.0d0 CL-EWKB::POINTZ-PRIMITIVE 3.0d0
63 CL-EWKB::POINTZM-PRIMITIVE 4.0d0)))
64 CL-EWKB::LINESTRING)
65
66
67 Drawing data with opengl (using cl-opengl):
68
69 Draw pointXX-primitive
70
71 (defun draw-point-primitive (point)
72 (cond
73 ((point-primitive-p point)
74 (gl:vertex
75 (point-primitive-x point)
76 (point-primitive-y point)))
77 ((pointz-primitive-p point)
78 (gl:vertex
79 (point-primitive-x point)
80 (point-primitive-y point)
81 (pointz-primitive-z point)))
82 ((pointm-primitive-p point)
83 (gl:vertex
84 (point-primitive-x point)
85 (point-primitive-y point)
86 0.0
87 (pointm-primitive-m point)))
88 ((pointzm-primitive-p point)
89 (gl:vertex
90 (point-primitive-x point)
91 (point-primitive-y point)
92 (pointz-primitive-z point)
93 (pointzm-primitive-m point)))))
94
95 Drawing objects
96
97 (defun draw-point (point)
98 (gl:with-primitives :points
f48fe3c @filonenko-mikhail fix readme
authored
99 (draw-point-primitive (point-primitive point))))
a946ec9 @filonenko-mikhail Create docs. Rename line-primitive to linear-ring
authored
100
f48fe3c @filonenko-mikhail fix readme
authored
101 (defun draw-points (line-string)
a946ec9 @filonenko-mikhail Create docs. Rename line-primitive to linear-ring
authored
102 (gl:with-primitives :line-strip
f48fe3c @filonenko-mikhail fix readme
authored
103 (map 'nil (lambda (point) (draw-point-primitive point))
104 (line-string-points-primitive line-string))))
a946ec9 @filonenko-mikhail Create docs. Rename line-primitive to linear-ring
authored
105
106
107 General drawing function
108
109 (defun draw-gisobject (object)
110 (cond
111 ((point-p object) (draw-point object))
f48fe3c @filonenko-mikhail fix readme
authored
112 ((line-string-p object) (draw-points object))))
Something went wrong with that request. Please try again.