Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit27708bd

Browse files
df7cbmsdemlei
authored andcommitted
Add smoc(order, spoint) function
1 parent403da2c commit27708bd

File tree

9 files changed

+67
-2
lines changed

9 files changed

+67
-2
lines changed

‎expected/moc.out

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,12 @@ SELECT smoc_disc(2, 0, 0, 3.2);
704704
0/0-11
705705
(1 row)
706706

707+
SELECT smoc(6, '(0,0)'::spoint);
708+
smoc
709+
---------
710+
6/19456
711+
(1 row)
712+
707713
SELECT smoc(1, '<(1,1),1>'::scircle);
708714
smoc
709715
---------------------------

‎healpix.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@ Datum pg_ring2nest(PG_FUNCTION_ARGS)
107107
PG_RETURN_INT64(ring2nest(c_nside(order),ring));
108108
}
109109

110-
statichpint64c_healpix_convert_nest(hpint64idx,int32from_order,
110+
hpint64
111+
c_healpix_convert_nest(hpint64idx,int32from_order,
111112
int32to_order)
112113
{
113114
check_order(to_order);

‎moc.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ PG_FUNCTION_INFO_V1(smoc_not_superset_spoint);
3535
PG_FUNCTION_INFO_V1(smoc_union);
3636
PG_FUNCTION_INFO_V1(smoc_intersection);
3737
PG_FUNCTION_INFO_V1(smoc_degrade);
38+
PG_FUNCTION_INFO_V1(smoc_spoint);
3839
PG_FUNCTION_INFO_V1(smoc_disc);
3940
PG_FUNCTION_INFO_V1(smoc_scircle);
4041
PG_FUNCTION_INFO_V1(smoc_spoly);
@@ -952,6 +953,33 @@ smoc_degrade(PG_FUNCTION_ARGS)
952953
PG_RETURN_POINTER(moc_ret);
953954
}
954955

956+
Datum
957+
smoc_spoint(PG_FUNCTION_ARGS)
958+
{
959+
intorder=PG_GETARG_INT32(0);
960+
SPoint*p= (SPoint*)PG_GETARG_POINTER(1);
961+
hpint64pixel,first,last;
962+
void*moc_in_context;
963+
int32moc_size;
964+
Smoc*moc_ret;
965+
966+
check_order(order);
967+
968+
pixel=healpix_nest_c(order,p);
969+
first=c_healpix_convert_nest(pixel,order,HEALPIX_MAX_ORDER);
970+
last=c_healpix_convert_nest(pixel+1,order,HEALPIX_MAX_ORDER);
971+
972+
moc_in_context=create_moc_in_context(moc_error_out);
973+
moc_healpix(moc_in_context,first,last,moc_error_out);
974+
975+
moc_size=VARHDRSZ+get_moc_size(moc_in_context,moc_error_out);
976+
moc_ret= (Smoc*)palloc0(moc_size);
977+
SET_VARSIZE(moc_ret,moc_size);
978+
979+
create_moc_release_context(moc_in_context,moc_ret,moc_error_out);
980+
PG_RETURN_POINTER(moc_ret);
981+
}
982+
955983
Datum
956984
smoc_disc(PG_FUNCTION_ARGS)
957985
{

‎pgs_healpix.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ void check_order(int order);
1717

1818
Datumpg_nest2ring(PG_FUNCTION_ARGS);
1919
Datumpg_ring2nest(PG_FUNCTION_ARGS);
20+
hpint64c_healpix_convert_nest(hpint64idx,int32from_order,int32to_order);
2021
Datumhealpix_convert_nest(PG_FUNCTION_ARGS);
2122
Datumhealpix_convert_ring(PG_FUNCTION_ARGS);
2223
Datumpg_nside2order(PG_FUNCTION_ARGS);

‎pgs_moc.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ Datum spoint_not_subset_smoc_c(SPoint*, Datum);
8686
Datumsmoc_union(PG_FUNCTION_ARGS);
8787
Datumsmoc_intersection(PG_FUNCTION_ARGS);
8888
Datumsmoc_degrade(PG_FUNCTION_ARGS);
89+
Datumsmoc_spoint(PG_FUNCTION_ARGS);
8990
Datumsmoc_disc(PG_FUNCTION_ARGS);
9091
Datumsmoc_scircle(PG_FUNCTION_ARGS);
9192
Datumsmoc_spoly(PG_FUNCTION_ARGS);

‎pgs_moc_ops.sql.in

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,16 @@ CREATE FUNCTION smoc_degrade ("order" int, smoc)
258258

259259
COMMENT ON FUNCTION smoc_degrade ("order" int, smoc) IS 'reduce order of smoc';
260260

261+
CREATE FUNCTION smoc ("order" int, spoint)
262+
RETURNS smoc
263+
AS 'MODULE_PATHNAME', 'smoc_spoint'
264+
LANGUAGE C
265+
PARALLEL SAFE
266+
IMMUTABLE
267+
STRICT;
268+
269+
COMMENT ON FUNCTION smoc ("order" int, spoint) IS 'constructs smoc of given order from spoint';
270+
261271
CREATE FUNCTION smoc_disc ("order" int, lng double precision, lat double precision, radius double precision)
262272
RETURNS smoc
263273
AS 'MODULE_PATHNAME'

‎pgs_process_moc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ void
150150
moc_round(void*moc_in_context,intorder,Smoc*moc_a,int32moc_a_end,
151151
pgs_error_handlererror_out);
152152

153+
void
154+
moc_healpix(void*moc_in_context,hpint64first,hpint64last,
155+
pgs_error_handlererror_out);
156+
153157
void
154158
moc_disc(void*moc_in_context,intorder,doubletheta,doublephi,doubleradius,
155159
pgs_error_handlererror_out);

‎process_moc.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -933,7 +933,7 @@ moc_round(void* moc_in_context, int order, Smoc* moc_a, int32 moc_a_end,
933933
{
934934
// page bumps
935935
int32 mod = (a + MOC_INTERVAL_SIZE) % PG_TOAST_PAGE_FRAGMENT;
936-
if (mod >0 && mod < MOC_INTERVAL_SIZE)
936+
if (mod >0 && mod <(int32)MOC_INTERVAL_SIZE)
937937
a += MOC_INTERVAL_SIZE - mod;
938938
moc_interval & x = *interval_ptr(moc_a, a);
939939

@@ -947,6 +947,18 @@ moc_round(void* moc_in_context, int order, Smoc* moc_a, int32 moc_a_end,
947947
PGS_CATCH
948948
}
949949

950+
void
951+
moc_healpix(void* moc_in_context, hpint64 first, hpint64 last,
952+
pgs_error_handler error_out)
953+
{
954+
moc_input* p =static_cast<moc_input*>(moc_in_context);
955+
moc_input & m = *p;
956+
PGS_TRY
957+
moc_map_entryinput(first, last);
958+
m.input_map.insert(m.input_map.end(), input);
959+
PGS_CATCH
960+
}
961+
950962
void
951963
moc_disc(void* moc_in_context,int order,double theta,double phi,double radius,
952964
pgs_error_handler error_out)

‎sql/moc.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ SELECT smoc_disc(2, 0, 0, 1);
153153
SELECT smoc_disc(0,0,0,3.2);
154154
SELECT smoc_disc(2,0,0,3.2);
155155

156+
SELECT smoc(6,'(0,0)'::spoint);
157+
156158
SELECT smoc(1,'<(1,1),1>'::scircle);
157159
SELECT smoc(3,'<(0,1.3),.5>'::scircle);
158160

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp