@@ -427,6 +427,28 @@ function gmt_free_mem(API::Ptr{Cvoid}, mem)
427427 ccall ((:gmt_free_func , libgmt), Cvoid, (Cstring, Ptr{Cvoid}, Bool, Cstring), GMT_, mem, true , " Julia" )
428428end
429429
430+ function gmt_centroid_area (API:: Ptr{Cvoid} , D, geo:: Int = 0 ):: Matrix{Float64}
431+ if (isa (D, Vector))
432+ mat = Matrix {Float64} (undef, length (D), 3 )
433+ for k in eachindex (D)
434+ t = gmt_centroid_area (API:: Ptr{Cvoid} , D[k]. data[:,1 ], D[k]. data[:,2 ], geo)
435+ mat[k, 1 ], mat[k, 2 ], mat[k, 3 ] = t[1 ], t[2 ], t[3 ]
436+ end
437+ mat
438+ else
439+ gmt_centroid_area (API:: Ptr{Cvoid} , D. data[:,1 ], D. data[:,2 ], geo)
440+ end
441+ end
442+
443+ function gmt_centroid_area (API:: Ptr{Cvoid} , x:: Vector{Float64} , y:: Vector{Float64} , geo:: Int = 0 ):: Matrix{Float64}
444+ # geo = 0 for Cartesian, !=0 for geographic
445+ pos = [0.0 0.0 0.0 ]
446+ area = ccall ((:gmt_centroid_area , libgmt), Cdouble, (Cstring, Ptr{Cdouble}, Ptr{Cdouble}, UInt64, Int32, Ptr{Cdouble}),
447+ GMT_Get_Ctrl (API), x, y, length (x), geo, pos)
448+ pos[3 ] = abs (area)
449+ return pos
450+ end
451+
430452#=
431453function get_common_R(API::Ptr{Cvoid})
432454 R = COMMON_R((false,false,false,false), false, 0, 0, 0, (0., 0., 0., 0., 0., 0.), (0., 0., 0., 0.), (0., 0.), map(UInt8, (string(repeat(" ",256))...,)))
0 commit comments