to_json is not producing json
matkoniecz opened this issue · 2 comments
matkoniecz commented
require 'rgeo/geo_json'
def point(name, lat, lon)
factory = RGeo::Cartesian.simple_factory(srid: 4326)
point = factory.point(lat, lon)
RGeo::GeoJSON::EntityFactory.instance.feature(point, {"name": name})
return point
end
geometries = []
geometries << point("Null Island", 0, 0)
geometries << point("Marker of former Prime Meridiam", 51.4779959, -0.0014862)
puts(RGeo::GeoJSON::EntityFactory.instance.feature_collection(geometries).to_json)
gives
"#<RGeo::GeoJSON::FeatureCollection:0xf0>"
not an expected json
jnicho02 commented
Hey Mateusz, fancy finding you here!
A while back now, but did you mean....
require 'rgeo/geo_json'
def feature(name, lat, lon)
factory = RGeo::Cartesian.simple_factory(srid: 4326)
point = factory.point(lon, lat) # it's x, y
feature = RGeo::GeoJSON::EntityFactory.instance.feature(point, id = nil, properties = {"name": name})
return feature
end
features = []
features << feature("Null Island", 0, 0)
features << feature("Marker of former Prime Meridian", 51.4779959, -0.0014862)
puts(RGeo::GeoJSON::EntityFactory.instance.feature_collection(features).to_json)
giving
[{"geometry":"POINT (0.0 0.0)","id":null,"properties":{"name":"Null Island"}},{"geometry":"POINT (-0.0014862 51.4779959)","id":null,"properties":{"name":"Marker of former Prime Meridian"}}]
?
matkoniecz commented
hmm, it looks OK and working as expected in your code (I have not run it)
lets close, I will reopen it in unlikely case that I reproduce it with a valid code