Class: RGeoServer::ShapefileInfo
- Inherits:
-
Object
- Object
- RGeoServer::ShapefileInfo
- Defined in:
- lib/rgeoserver/utils/shapefile_info.rb
Defined Under Namespace
Classes: ShapefileInfoGeometryNotExpected
Instance Attribute Summary collapse
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
Instance Method Summary collapse
- #bounds ⇒ Object
-
#initialize(file_path) ⇒ ShapefileInfo
constructor
A new instance of ShapefileInfo.
- #srid ⇒ Object
Constructor Details
#initialize(file_path) ⇒ ShapefileInfo
Returns a new instance of ShapefileInfo.
19 20 21 |
# File 'lib/rgeoserver/utils/shapefile_info.rb', line 19 def initialize file_path @file_path = file_path end |
Instance Attribute Details
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
17 18 19 |
# File 'lib/rgeoserver/utils/shapefile_info.rb', line 17 def file_path @file_path end |
Instance Method Details
#bounds ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rgeoserver/utils/shapefile_info.rb', line 23 def bounds resource_init bbox = BoundingBox.new RGeo::Shapefile::Reader.open(@shp_path) do |shp| shp.each do |record| geometry = record.geometry envelope = geometry.envelope envelope_type = envelope.geometry_type points = case envelope_type when RGeo::Feature::Point [envelope] when RGeo::Feature::Polygon envelope.exterior_ring.points else raise ShapefileInfoGeometryNotExpected, envelope_type end points.each { |point| bbox.add point.x, point.y } end end resource_destroy bbox. if [bbox.minx, bbox.miny] == [bbox.maxx, bbox.maxy] bbox end |
#srid ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/rgeoserver/utils/shapefile_info.rb', line 51 def srid resource_init srid = 0 RGeo::Shapefile::Reader.open(@shp_path) do |shp| srid = shp.factory.srid end resource_destroy srid end |