Sqlserver
 sql >> Base de données >  >> RDS >> Sqlserver

Stockage de la colonne 'Point' de ShapeFile

Je suggérerais de stocker l'ensemble du polygone en tant que type de géométrie. Si/quand vous avez besoin de le "convertir" en géographie, utilisez les méthodes géographiques STNumPoints et STPointN pour extraire les points individuels en séquence et les convertir selon le cas.

En parlant de conversion, dans quel format sont vos données maintenant ? Je ne vois pas d'informations lat/long là-bas, mais peut-être qu'il me manque quelque chose.

Edit :Voici une solution que je viens de coder.

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()