chiark / gitweb /
Privacy control UI
[ypp-sc-tools.db-test.git] / pctb / structure.c
index 0c9750c5f5bd45c4222db71686816dee5b86b464..35cf0d9507da3335dbe47df403e9992808bc8e85 100644 (file)
@@ -46,6 +46,8 @@ static int colrightx[INTERESTING_COLUMNS];
 static int text_h=-1, columns=-1;
 static OcrReader *rd;
 
+char *archipelago, *island;
+
 #define OTHERCOORD_x y
 #define OTHERCOORD_y x
 
@@ -468,6 +470,8 @@ void analyse(FILE *tsv_output) {
     if (!rd)
       rd= ocr_init(text_h);
 
+    progress("Scanning page %d...",page);
+
     for (tryrect= +cim->h; tryrect >= -cim->h; tryrect--) {
       find_commodity(tryrect, &thisr);
       if (thisr.tl.x < 0)
@@ -490,6 +494,7 @@ void analyse(FILE *tsv_output) {
       sysassert(!fflush(tsv_output));
     }
   }
+  progress("Commodity table scan complete.");
 }
 
 //static Rect islandnamer;
@@ -528,7 +533,6 @@ void find_islandname(void) {
   debug_rect("sunshiner",1, sunshiner);
 
   identify_rgbimage(ri, sunshiner, sunshine, "sunshine widget");
-  fprintf(stderr,"sunshine: `%s'\n",sunshine);
   
   if (!memcmp(sunshine,"Ship ",5)) {
     Rect islandnamer;
@@ -538,11 +542,8 @@ void find_islandname(void) {
     islandnamer.tl.y=                 128;
     islandnamer.br.y=                 156;
 
-#define IR_VSHRINK_MUST(CONDMUST,PRWHY) \
-    do{ if (!(CONDMUST)) goto not_in_radar; }while(0)
-
-    ADJUST_BOX(islandnamer,"o",5, 0,      IR_VSHRINK_MUST, tl,y,+1);
-    ADJUST_BOX(islandnamer,"o",5, cim->h, IR_VSHRINK_MUST, br,y,-1);
+    ADJUST_BOX(islandnamer,"o",5, 0,      MUST, tl,y,+1);
+    ADJUST_BOX(islandnamer,"o",5, cim->h, MUST, br,y,-1);
 
     debug_rect("islandnamer",0, islandnamer);
 //    int larger_islandnamebry= islandnamer.tl.y + 25;
@@ -562,15 +563,14 @@ void find_islandname(void) {
       }
 
     identify_rgbimage(ri, islandnamer, archisland, "island");
-    fprintf(stderr,"radar: `%s'\n",archisland);
-
-    assert(!"radar ok");
-  
-  not_in_radar:
-    assert(!"not in radar?");
   } else {
     assert(!"not vessel");
   }
 
+  char *delim= strstr(archisland," - ");
+  assert(delim);
+  archipelago= masprintf("%.*s", delim-archisland, archisland);
+  island= masprintf("%s", delim+3);
+
   free(ri);
 }