Skip to content
Snippets Groups Projects
ccw_orient.f90 766 B
module ccw_orient_m

  implicit none

contains

  subroutine ccw_orient(c)

    ! Revert order of points in contour if area is negative. We are
    ! choosing the GeoJSon convention: counterclockwise external ring,
    ! over the ESRI shapefile convention, which is opposite. The main
    ! point is probably to follow a convention rather than let the
    ! polygon have random order.

    use derived_types, only: ssh_contour

    type(ssh_contour), intent(inout):: c

    !---------------------------------------------------------------------

    if (c%area < 0) then
       ! Reverse orientation:
       c%polyline%points = c%polyline%points(:, c%polyline%n_points:1:- 1)
       c%area = - c%area
    end if

  end subroutine ccw_orient

end module ccw_orient_m