Report sign/house in significant transits; back up user.properties outside dist/
This commit is contained in:
@@ -17,6 +17,11 @@ static const char *const k_aspect_slug[5] = {
|
||||
"conjunction", "sextile", "square", "trine", "opposition",
|
||||
};
|
||||
|
||||
static const char *const k_sign_slug[12] = {
|
||||
"aries", "taurus", "gemini", "cancer", "leo", "virgo",
|
||||
"libra", "scorpio", "sagittarius", "capricorn", "aquarius", "pisces",
|
||||
};
|
||||
|
||||
static bool body_from_slug(const char *slug, Body *out) {
|
||||
for (int i = 0; i < NUM_BODIES; i++) {
|
||||
if (strcmp(slug, k_body_slug[i]) == 0) {
|
||||
@@ -27,6 +32,41 @@ static bool body_from_slug(const char *slug, Body *out) {
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool sign_from_slug(const char *slug, ZodiacSign *out) {
|
||||
for (int i = 0; i < 12; i++) {
|
||||
if (strcmp(slug, k_sign_slug[i]) == 0) {
|
||||
*out = (ZodiacSign)i;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Fills out[NUM_BODIES] from a "bodies" JSON array, the shape shared by
|
||||
* both "natal" and "transits" (see reading_print_json in engine/src/
|
||||
* reading.c). Used only for sign/house context in significant-event
|
||||
* reporting, not for scoring, so this is deliberately lenient: an entry
|
||||
* with an unrecognized/missing "body" slug is skipped, and a missing
|
||||
* "house" leaves that body's house at 0 - not a valid whole-sign house
|
||||
* number (always 1-12), so callers use house == 0 as "no position data
|
||||
* available" rather than this failing the whole load. */
|
||||
static void parse_bodies(const JsonValue *bodies, PlanetPosition out[NUM_BODIES]) {
|
||||
int count = json_array_count(bodies);
|
||||
for (int i = 0; i < count; i++) {
|
||||
const JsonValue *item = json_array_get(bodies, i);
|
||||
Body body;
|
||||
if (!body_from_slug(json_as_string(json_object_get(item, "body")), &body)) continue;
|
||||
|
||||
ZodiacSign sign;
|
||||
if (sign_from_slug(json_as_string(json_object_get(item, "sign")), &sign)) {
|
||||
out[body].sign = sign;
|
||||
}
|
||||
out[body].degree_in_sign = json_as_number(json_object_get(item, "degree_in_sign"));
|
||||
out[body].ecliptic_longitude = json_as_number(json_object_get(item, "ecliptic_longitude"));
|
||||
out[body].house = (int)json_as_number(json_object_get(item, "house"));
|
||||
}
|
||||
}
|
||||
|
||||
static bool aspect_type_from_slug(const char *slug, AspectType *out) {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (strcmp(slug, k_aspect_slug[i]) == 0) {
|
||||
@@ -78,6 +118,10 @@ bool reading_load_json(const char *text, size_t length, DailyReading *out) {
|
||||
}
|
||||
out->transits.aspect_count = filled;
|
||||
|
||||
const JsonValue *natal = json_object_get(root, "natal");
|
||||
parse_bodies(natal ? json_object_get(natal, "bodies") : NULL, out->natal.bodies);
|
||||
parse_bodies(json_object_get(transits, "bodies"), out->transits.bodies);
|
||||
|
||||
json_free(root);
|
||||
return ok;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user