global_coastlines.lua


NAME
    global_coastlines

FUNCTION
    global_coastlines(file, zoffset, Atlantic)

NOTES
    Create a line obect containing global coastlines.

    If Atlantic is true, the map center will be the Atlantic,
    i.e. longitude starts at -180 degree.

INPUTS
    file      - GSHHS file name
    zoffset   - z-coordinate of the map frame
    Atlantic  - true or false

OUTPUTS
    An zeLine object

SOURCE

require("register")

function global_coastlines(file, zoffset, Atlantic)
    local shape, xyz = zeGrf.new("line", "vertex")
    shape:set{type = "lines", vertex = xyz}
	local arr, bio = zeUtl.new("double", "bio")
	bio:open(file)
	if Atlantic then
    	bio:gshhs("land", 0, 180, -90, 90, arr)
    	arr:insert(2, zoffset)
        xyz:add(arr)
        bio:rewind()
    	bio:gshhs("land", 180, 360, -90, 90, arr)
    	local vec = zeUtl.new("double")
    	arr:getarr(0, vec)
    	vec:sub(360)
    	arr:setarr(0, vec)
    	arr:insert(2, zoffset)
        xyz:add(arr)
	else
    	bio:gshhs("land", 0, 360, -90, 90, arr)
    	arr:insert(2, zoffset)
        xyz:add(arr)
    end
    return shape
end