Creado por
TheCoffeMaker / @TheCoffeMaker
opensas / @develsas
EPSG:4326 para almacenar la información y realizar operaciones
EPSG:3857 para desplegar la información en pantalla
insert into test( the_geom )
values (
ST_GeomFromText(
'POINT(-58.38145 -34.60368)'
, 4326
)
)
select *,
ST_SRID(the_geom)
as geom_srid,
ST_SRID(the_geom_webmercator)
as geom_webmercator_srid
from test
select
1 as cartodb_id,
'Obelisco' as nombre,
ST_Transform(
ST_GeomFromText(
'POINT(-58.38145 -34.60368)'
, 4326
)
, 3857
) as the_geom_webmercator
select
1 as cartodb_id,
'Mi poligono' as nombre,
ST_Transform(
ST_GeomFromText(
'POLYGON((
-58.38145 -34.60368,
-58.48145 -34.60368,
-58.48145 -34.70368,
-58.38145 -34.60368
))'
, 4326
)
, 3857
) as the_geom_webmercator
select
*
from
teatros
order by
ST_Distance(
the_geom,
ST_GeomFromText(
'POINT(-58.38145 -34.60368)'
, 4326
)
)
limit 150
select
1 as cartodb_id,
ST_Buffer(
ST_Transform(
ST_GeomFromText(
'POINT(-58.38145 -34.60368)'
, 4326
)
, 3857
)
, 500
) as the_geom_webmercator
select
1 as cartodb_id,
ST_Buffer(
ST_Transform(
ST_GeomFromText('POLYGON((
-58.38145 -34.60368, -58.48145 -34.60368, -58.48145 -34.70368, -58.38145 -34.60368
))', 4326)
, 3857
)
, 1500) as the_geom_webmercator
union
select
2 as cartodb_id,
ST_Transform(
ST_GeomFromText('POLYGON((
-58.38145 -34.60368, -58.48145 -34.60368, -58.48145 -34.70368, -58.38145 -34.60368
))', 4326)
, 3857
) as the_geom_webmercator
select
*
from
teatros
where
ST_Within(
the_geom_webmercator,
ST_Buffer(
ST_Transform(
ST_GeomFromText(
'POINT(-58.38145 -34.60368)'
, 4326
)
, 3857
)
, 500
)
)
select
*,
(
select count(*)
from teatros
where ST_Within(teatros.the_geom, caba.the_geom)
) as teatros
from caba
select
tipo, subtipo, nombre, direccion, telefono, email, web, lat, lon
from cultura
where (
ST_Within(
the_geom,
ST_Envelope(
ST_GeomFromText(
'LINESTRING(
-58.456084263829254 -34.58568073843928,
-58.328412043543786 -34.622176987831935
)', 4326
)
)
)
) and (
lower(nombre) like '%corrientes%' or lower(direccion) like '%corrientes%'
) and (
lower(subtipo) in ('salas teatrales')
)
select
1 as cartodb_id,
ST_Transform(
ST_GeomFromText(
'LINESTRING(
-58.456084263829254 -34.58568073843928,
-58.328412043543786 -34.622176987831935
)', 4326
)
, 3857
) as the_geom_webmercator
select
1 as cartodb_id,
ST_Transform(
ST_Envelope(
ST_GeomFromText(
'LINESTRING(
-58.456084263829254 -34.58568073843928,
-58.328412043543786 -34.622176987831935
)', 4326
)
)
, 3857
) as the_geom_webmercator
select
*
from
teatros
where (
ST_Within(
the_geom,
ST_Envelope(
ST_GeomFromText(
'LINESTRING(
-58.456084263829254 -34.58568073843928,
-58.328412043543786 -34.622176987831935
)', 4326
)
)
)
) and (
lower(nombre) like '%corrientes%' or lower(direccion) like '%corrientes%'
)