Skip to content

Commit

Permalink
Add MOC creation from STC-S string
Browse files Browse the repository at this point in the history
  • Loading branch information
fxpineau committed Dec 12, 2023
1 parent 94b2117 commit 3442876
Show file tree
Hide file tree
Showing 4 changed files with 454 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[package]
name = "moc"
version = "0.11.3"
version = "0.12.0"
authors = [
"F.-X. Pineau <francois-xavier.pineau@astro.unistra.fr>",
"Matthieu Baumann <matthieu.baumann@astro.unistra.fr>"
Expand Down Expand Up @@ -59,6 +59,9 @@ rayon = "1.5.1"
flate2 = "1.0.22" # Compression/decompression
png = "0.17" # For png
slab = { version = "0.4", optional = true }
stc = { git = "https://github.com/cds-astro/cds-stc-rust" }
thiserror = "1.0" # For STC-S (quick-error should be replaced by thiserror everywhere)


[dev-dependencies]
rand = "0.8.3"
Expand Down
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,40 @@ pub fn or<T, Q, U, R, I1, J1, K1, I2, J2, K2>(
whether the index is a single index, a range lower bound or a range upper bound
* [ ] Make a PostgresQL wrapper using e.g. [pgx](https://github.com/zombodb/pgx/)?


## WARNING about the STC-S to MOC function

STC-S parsing is ensured by the [STC crate](https://github.com/cds-astro/cds-stc-rust).

Current discrepancies between the STC standard and this implementation:

* The `DIFFERENCE` operation has been implemented as being a `symmetric difference`
+ why? probably because:
1. I am biased towards Boolean algebra, it as `XOR`
(exclusive `OR` or symmetric difference) but no `Difference`
2. I read parts of the STC standard after the STC-S implementation
3. `XOR` is already implemented in [cdshleapix](https://github.com/cds-astro/cds-healpix-rust), but `DIFFERENCE` is not.
+ has stated in the STC standard: `R1R2 = R1 AND (NOT R2))`;
but also: `R1 - R2 = R1 AND (R1 XOR R2)`, and
`XOR = (R1 OR R2) AND (NOT (R1 AND R2))` is more complex that `DIFFERENCE`
(so is worth having implented?).
* For `Polygon`: we do not use the STC convention
+ we support self-intersecting polygons
+ we generally return the smallest area polygon (use `NOT` to get its complement!)
+ one convention could be to use an additional (last) provided points as a control point
- note that for convex polygons, the control point could be the vertices gravity center
- in a GUI, a user could define the inner part of the polygon by a final click
+ why?
1. efficient algorithms dealing with polygons supports self-intersecting polygons
2. to support arbitrary defined polygons by a user clicking in a viewer such as Aladin or Aladin Lite
3. [cdshleapix](https://github.com/cds-astro/cds-healpix-rust) is based on self-intersecting polygons
* For `Box`: a position angle can be added as a last parameter, right after `bsize`.

So far, we reject STC-S having:
* a frame different from `ICRS`
* a flavor different from `Spher2`
* units different from `degrees`

## License

Like most projects in Rust, this project is licensed under either of
Expand Down
1 change: 1 addition & 0 deletions src/deser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ pub mod json;
pub mod fits;
pub mod gz;
pub mod img;
pub mod stcs;
Loading

0 comments on commit 3442876

Please sign in to comment.