Module: XData
- Defined in:
- lib/xdata/file_reader.rb,
lib/xdata.rb,
lib/xdata/util.rb
Overview
factory = RGeo::Geographic.projected_factory(:projection_proj4 => ‘+proj=sterea lat_0=52.15616055555555 lon_0=5.38763888888889 k=0.9999079 x_0=155000 y_0=463000 ellps=bessel units=m no_defs ’) rd_factory = RGeo::Geographic.spherical_factory(:srid => 28992, :proj4 => amersfoort-rd-new) curved_factory = RGeo::Geographic.spherical_factory(:srid => 4326)
Defined Under Namespace
Classes: Exception, FileReader
Constant Summary collapse
- VERSION =
'0.1.2'
- RD_P =
Proj4::Projection.new('+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.9999079 +x_0=155000 +y_0=463000 +ellps=bessel +units=m +no_defs')
- LL_P =
Proj4::Projection.new('+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs')
Class Method Summary collapse
Instance Method Summary collapse
-
#jsonlog(o) ⇒ Object
for debugging purposes…
- #toPolygon(twopoints) ⇒ Object
Class Method Details
.headers(url) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/xdata/util.rb', line 55 def self.headers(url) begin uri = URI(url) http = Net::HTTP.new(uri.host, uri.port) if url.scheme == 'https' http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE end return http.head(uri.path.blank? ? "/" : uri.path).to_hash rescue end nil end |
Instance Method Details
#jsonlog(o) ⇒ Object
for debugging purposes…
70 71 72 |
# File 'lib/xdata/util.rb', line 70 def jsonlog(o) STDERR.puts JSON.pretty_generate({ o.class.to_s => o }) end |
#toPolygon(twopoints) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/xdata/util.rb', line 33 def toPolygon(twopoints) lon1 = twopoints[0].lon lat1 = twopoints[0].lat lon2 = twopoints[1].lon lat2 = twopoints[1].lat if lon1.between?(-7000.0,300000.0) and lat1.between?(289000.0,629000.0) # Simple minded check for Dutch new rd system a = XData.rd_to_wgs84(lon1,lat1) lon1 = a[0]; lat1 = a[1] a = XData.rd_to_wgs84(lon2,lat2) lon2 = a[0]; lat2 = a[1] end return { type: 'Polygon', coordinates: [[lon1,lat1], [lon1,lat2], [lon2,lat2], [lon2,lat1], [lon1,lat1]] } end |