Sha256: 87289f793cb368bf88896867d7ca4013e0778faafc95bf8d655b87b63a261589

Contents?: true

Size: 1.46 KB

Versions: 6

Compression:

Stored size: 1.46 KB

Contents

# unpack polygon
# point is coded in GeoJSON
# Reader - ADIwg JSON V1 to internal data structure

# History:
# 	Stan Smith 2013-11-18 original script
#   Stan Smith 2014-04-30 reorganized for json schema 0.3.0
#   Stan Smith 2014-05-23 modified to handle MultiPolygon objects
#   Stan Smith 2014-07-07 resolve require statements using Mdtranslator.reader_module

require ADIWG::Mdtranslator.reader_module('module_coordinates', $response[:readerVersionUsed])

module Adiwg_Polygon

	def self.unpack(aCoords, geoType)
		intMetadataClass = InternalMetadata.new
		intGeometry = intMetadataClass.newGeometry
		intGeometry[:geoType] = geoType

		# polygon - coordinate(s)
		if geoType == 'Polygon'
			intGeometry[:geometry] = splitPolygons(aCoords)
			intGeometry[:dimension] = Adiwg_Coordinates.getDimension(intGeometry[:geometry][:exteriorRing])
		elsif geoType == 'MultiPolygon'
			aPolySets = Array.new
			aCoords.each do |aPolygonSet|
				aPolySets << splitPolygons(aPolygonSet)
			end
			intGeometry[:geometry] = aPolySets
		end

		return intGeometry
	end

	def self.splitPolygons(aPolySet)
		intMetadataClass = InternalMetadata.new
		intPolygonSet = intMetadataClass.newPolygonSet

		# first polygon in set is a bounding exterior ring
		# all subsequent polygons are exclusion rings
		i = 0
		aPolySet.each do |aPolygon|
			i += 1
			if i == 1
				intPolygonSet[:exteriorRing] = aPolygon
			else
				intPolygonSet[:exclusionRings] << aPolygon
			end

		end

		return intPolygonSet
	end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
adiwg-mdtranslator-0.9.0 lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.9.0/module_polygon.rb
adiwg-mdtranslator-0.8.6 lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_polygon.rb
adiwg-mdtranslator-0.8.5 lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_polygon.rb
adiwg-mdtranslator-0.8.2 lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_polygon.rb
adiwg-mdtranslator-0.8.1 lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_polygon.rb
adiwg-mdtranslator-0.8.0 lib/adiwg/mdtranslator/readers/adiwgJson/modules_0.8.0/module_polygon.rb