File tree 1 file changed +33
-0
lines changed
1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -126,6 +126,39 @@ func (ctx *Context) Create(definition string) (*PJ, error) {
126
126
return & p , nil
127
127
}
128
128
129
+ func (ctx * Context ) CreateCRS2CRS (srcDefn , dstDefn string ) (* PJ , error ) {
130
+ if ! ctx .opened {
131
+ return & PJ {}, errContextClosed
132
+ }
133
+
134
+ srcDefnC := C .CString (srcDefn )
135
+ dstDefnC := C .CString (dstDefn )
136
+ defer func () {
137
+ C .free (unsafe .Pointer (srcDefnC ))
138
+ C .free (unsafe .Pointer (dstDefnC ))
139
+ }()
140
+
141
+ pj := C .proj_create_crs_to_crs (ctx .pj_context , srcDefnC , dstDefnC , nil )
142
+ if pj == nil {
143
+ errno := C .proj_context_errno (ctx .pj_context )
144
+ err := C .GoString (C .proj_errno_string (errno ))
145
+ return & PJ {}, errors .New (err )
146
+ }
147
+
148
+ p := PJ {
149
+ opened : true ,
150
+ context : ctx ,
151
+ index : ctx .counter ,
152
+ pj : pj ,
153
+ }
154
+
155
+ ctx .projections [ctx .counter ] = & p
156
+ ctx .counter ++
157
+
158
+ runtime .SetFinalizer (& p , (* PJ ).Close )
159
+ return & p , nil
160
+ }
161
+
129
162
// Close a transformation object
130
163
func (p * PJ ) Close () {
131
164
if p .opened {
You can’t perform that action at this time.
0 commit comments