Sha256: d7c71c6ecbd7fa05a79a953b4b97772cc05acc6a8b47ba830321d47b03a9aa53
Contents?: true
Size: 1.45 KB
Versions: 1
Compression:
Stored size: 1.45 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 Md_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] = Md_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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
adiwg-mdtranslator-0.10.2 | lib/adiwg/mdtranslator/readers/mdJson/modules_0.9.0/module_polygon.rb |