[Georuby-devel] Approaches for default SRID different than -1, with postgis?

Tilmann Singer tils at tils.net
Thu Feb 28 07:02:48 EST 2008


* Guilhem Vellut <guilhem.vellut at gmail.com> [20080227 10:04]:
> To change the default SRID, you can also do it without modifying the
> source file by putting somewhere :
> GeoRuby::SimpleFeatures::DEFAULT_SRID = 4326. You will get a warning
> though.

Thanks. I'll do that and wrap it with

silence_warnings { }

to avoid the warning. I guess a class method would be nicer but I
don't know how configurable it is supposed to be. Having it as a
constant communicates to the user "This is not configurable, you
should not change it". I tried to propose a patch to change it to a
class variable and a setter, but realized that the constant is used in
many method declarations as the default value, like this:

def self.from_x_y(x,y,srid=DEFAULT_SRID)
...
end

and this cannot be just changed to

def self.from_x_y(x,y,srid=@@default_srid)
...
end

but rather needs to be something like this to avoid setting the
default to the value at method definition time rather then runtime

def self.from_x_y(x,y,srid=nil)
srid ||= @@default_srid
...
end

If you think that this is the right approach then I'll go ahead with a
patch and also try to write a test for it.

> About the reason why the default SRID (actually the -1 SRID
> originally) is not output in the ewkb and ewkt, it is possible that
> there may not be any valid reason. I'll check if it is ok for postgis
> and mysql to do withouth the check when the SRID is -1 and I will
> apply your patch if this is the case.

Thanks


Til

-- 
Sent from Plazes Berlin, Berlin
https://plazes.com/whereis/til?                   http://tils.net
Tilmann Singer                                +49-176 20 19 51 69


More information about the Georuby-devel mailing list