Ignore:
Timestamp:
2020-02-26T21:19:23+13:00 (4 years ago)
Author:
ak19
Message:

As Dr Bainbridge suggested, code now opens a new firefox tab with a subsequent geojson map after Enter pressed. Further, the firefox webconsole screenshot command is now already added to copy buffer which works on my Ubuntu.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • other-projects/maori-lang-detection/src/org/greenstone/atea/SummaryTool.java

    r33978 r33981  
    189189    if(outFile.exists()) {
    190190        logger.error("WARN: Full web page urls list file already exists: " + fullFileName);
    191         logger.error("      Will not overwrite. Delete file manually and re-run this program.");
     191        logger.error("      Will not overwrite as it may already have been processed.");
     192        logger.error("      If you're sure, rename/delete the file manually and re-run this program.");
    192193        return;
    193194    }
     
    356357     */
    357358    public static void main(String args[]) {
     359    boolean doDebug = false;
     360   
    358361    int oldDebugMode = SafeProcess.DEBUG;
    359     SafeProcess.DEBUG = 0;
     362    SafeProcess.DEBUG = doDebug ? 1 : 0;
    360363
    361364    if(args.length >= 2) {
     
    366369    try (
    367370         MongoDBQueryer mongodb = new MongoDBQueryer();
     371         BufferedReader systemIn = new BufferedReader(new InputStreamReader(System.in, "UTF-8"));
    368372         ) {
    369373
     
    397401        } else {       
    398402
    399         // calculating sample size works:
     403        // TEST: calculating sample size works:
    400404        //System.err.println("For N = " + 4360 + ", n = " + listing.calcSampleSize(4360));
    401405        //System.err.println("For N = " + 681 + ", n = " + listing.calcSampleSize(681));
     
    434438            String geoJsonFilename = mapData.writeFeaturesGeoJsonToFile(CountryCodeCountsMapData.SUPPRESS_MAPDATA_DISPLAY);
    435439           
    436 
    437             /*
    438             // Ensure the geo-json file generated exists
     440            // Ensuring the geo-json file generated exists
    439441            //String geoJsonFilename = outFolder + File.separator
    440             //+ GEOJSON_FEATURES_FILE_PREFIX + tablefilename;
    441            
     442            //+ GEOJSON_FEATURES_FILE_PREFIX + tablefilename;           
    442443            File geoJsonFile = new File(geoJsonFilename);
    443444            if(!geoJsonFile.exists()) {
    444445            logger.info("@@@ geoJson file " + geoJsonFilename + " not generated!");
    445             continue;
    446             }
    447             */
    448             logger.info("**** Wrote mapdata to file " + geoJsonFilename);
    449             //logger.info("     Paste the file's geojson contents into "
    450             //+ "the editor at " + CountryCodeCountsMapData.GEOJSON_MAP_TOOL_URL
    451             //+ " to see the data arranged on a world map");           
    452             logger.info("Total count for query: " + mapData.getTotalCount());
     446            //continue;
     447            }
     448            else {
     449            if(doDebug) {
     450                logger.info("**** Wrote mapdata to file " + geoJsonFilename);
     451                //logger.info("     Paste the file's geojson contents into "
     452                //+ "the editor at " + CountryCodeCountsMapData.GEOJSON_MAP_TOOL_URL
     453                //+ " to see the data arranged on a world map");
     454                logger.info("Total count for query: " + mapData.getTotalCount());
     455            }
     456            }           
     457           
    453458           
    454459            // Running the command:
     
    456461            // to confirm if the JSON in the provided json file parses/is valid JSON.
    457462
    458             /*
     463           
    459464            String[] cmdArgs = {"python", "-mjson.tool", geoJsonFilename};
    460465            SafeProcess p = new SafeProcess(cmdArgs);
    461466            int retVal = p.runProcess();
    462             logger.info("\nJson validation tool returned with value: " + retVal);
    463             if(retVal == 0) {
    464             logger.info("Valid geo json.");
    465             } else {
     467
     468            if(retVal != 0) {
     469            logger.info("\nJson validation tool returned with value: " + retVal);
    466470            logger.error("   std out: " + p.getStdOutput());
    467471            logger.error("   std err: " + p.getStdError());
    468472            logger.error("INVALID geo json generated. Not attempting screenshot of map.");
     473            logger.info("");
    469474            continue;
    470475            }
    471             */
    472            
    473             /*boolean uriEncoded = true;
    474             String mapDataEncodedStr = mapData.getFeaturesGeoJsonString(uriEncoded);
    475             logger.info("Encoded string: " + mapDataEncodedStr);
    476             */
     476           
    477477           
    478478            //logger.info("Data URL string: " + mapData.getAsMapURL());
    479479            logger.info("");
    480480            //mapData.geoJsonMapScreenshot(outFolder, tablefilename);
    481             mapData.getGeoJSONMapScreenshotCommand(outFolder, tablefilename);
     481            mapData.getGeoJSONMapScreenshotCommand(outFolder, tablefilename.replace(".json", ""));
    482482            logger.info("---");
    483483
     484
     485            System.out.println("Press Enter to continue >");
     486            String userEntered = "";
     487            while((userEntered = systemIn.readLine()) != null) {
     488            if(userEntered.equals("")) { // line read and empty
     489                break;
     490            }
     491            else {                         
     492                System.out.println("Press Enter to continue >");
     493            }
     494            }
     495           
    484496            // TODO: Remove break. For debugging: breaks after first table -> map conversion.
    485497            //break;
Note: See TracChangeset for help on using the changeset viewer.