sql >> Base de Datos >  >> RDS >> Sqlserver

Almacenamiento de la columna 'Punto' de ShapeFile

Sugeriría almacenar todo el polígono como un tipo de geometría. Si necesita "convertirlo" a geografía, use los métodos de geografía STNumPoints y STPointN para extraer los puntos individuales en secuencia y convertirlos según corresponda.

Hablando de la conversión, ¿en qué formato están sus datos ahora? No veo información de latitud/longitud allí, pero tal vez me esté perdiendo algo.

Editar:aquí hay una solución que acabo de codificar.

use tempdb;
create table tally (i int not null);
with 
    a as (select 1 as [i] union select 0),
    b as (select 1 as [i] from a as [a1] cross join a as [a2]),
    c as (select 1 as [i] from b as [a1] cross join b as [a2]),
    d as (select 1 as [i] from c as [a1] cross join c as [a2]),
    e as (select 1 as [i] from d as [a1] cross join d as [a2])
insert into tally
select row_number() over (order by i) from e
create unique clustered index [CI_Tally] on tally (i)

create table ace (g geometry)
insert into ace (g)
values (geometry::STGeomFromText(<<your polygon string here>>, 0));

select i, g.STPointN(t.i), g.STPointN(t.i).STAsText()
from ace as [a]
cross join tally as [t]
where t.i <= g.STNumPoints()