public void setDateRange(DateTime minDate, DateTime maxDate, int tickCount) throws Exception { /* validate dates */ long minDateTS = (minDate != null) ? minDate.getTimeSec() : 0L; long maxDateTS = (maxDate != null) ? maxDate.getTimeSec() : 0L; if ((minDate == null) || (minDateTS < MIN_DATE) || (maxDate == null) || (maxDateTS < MIN_DATE) || (minDateTS >= maxDateTS) || ((maxDateTS - minDateTS) <= 60L)) { throw new Exception("Invalid Date range specification"); } /* adjust 'maxDateTS' to make sure (maxDateTS - minDateTS) is a multiple of 'tickCount' */ maxDateTS += (maxDateTS - minDateTS) % tickCount; /* vars */ this.minDateTS = minDateTS; this.maxDateTS = maxDateTS; this.timeZone = minDate.getTimeZone(); this.xTickCount = (tickCount > 0) ? tickCount : 6; }
/** ** Main entry point for testing/debugging ** @param argv Comand-line arguments */ public static void main(String argv[]) { RTConfig.setCommandLineArgs(argv); /* help */ if (RTConfig.hasProperty(ARG_HELP)) { _usage(); System.exit(1); // control does not reach here } /* extra args */ String extraArgs = RTConfig.getString(ARG_EXTRA, ""); if (!StringTools.isBlank(extraArgs)) { // Print.logInfo("Extra: " + extraArgs); RTProperties cfgProps = RTConfig.getConfigFileProperties(); if (extraArgs.indexOf(",") > 0) { cfgProps.setProperties(extraArgs, ','); } else { cfgProps.setProperties(extraArgs); } // cfgProps.printProperties(""); } /* special case "expire" */ String ARG_EXPIRE = "expire"; RTProperties expireRTP = RTConfig.getPropertiesForKey(ARG_EXPIRE, false); if (expireRTP != null) { Print.errPrintln("\n'expire' cannot be defined."); System.exit(1); } /* args */ File directory = RTConfig.getFile(ARG_DIR, null); String templateName = StringTools.trim(RTConfig.getString(ARG_OPTIONAL, RTConfig.getString(ARG_TEMPLATE, ""))); boolean isOptional = RTConfig.hasProperty(ARG_OPTIONAL); String packageName = StringTools.trim(RTConfig.getString(ARG_PACKAGE, null)); String outputName = RTConfig.getString(ARG_OUTPUT, ""); boolean overwrite = RTConfig.getBoolean(ARG_OVERWRITE, false); /* cannot specify "-output=inline" if internal template specified */ if (StringTools.isBlank(outputName) || outputName.equalsIgnoreCase("stdout")) { // -- output will be to "stdout" outputName = ""; } else if (outputName.equalsIgnoreCase("inline")) { // -- output will be to input file if (templateName.startsWith(TEMPLATE_)) { // -- @template not allowed with "inline" Print.errPrintln("\nError: Cannot specify '-output=inline' with internal template"); _usage(); System.exit(1); // control does not reach here } else if (isOptional) { // -- optional not allowed with "inline" Print.errPrintln("\nError: Cannot specify '-output=inline' with optional template"); _usage(); System.exit(1); // control does not reach here } else if (!templateName.startsWith("*")) { // -- output to input file outputName = templateName; } } else { // -- output to specified file if (templateName.startsWith("*")) { // -- template specifies a file-glob Print.errPrintln( "\nError: Cannot specify '-output=FILE' for recursize template specification"); _usage(); System.exit(1); // control does not reach here } } /* template name file? */ if (templateName.startsWith("*")) { if (isOptional) { // -- optional not allowed with glob file specification Print.errPrintln("\nError: Cannot specify optional '-template?=[**/]*.java'"); _usage(); System.exit(1); // control does not reach here } } else { File file = (directory != null) ? new File(directory, templateName) : new File(templateName); if (!file.isFile() && isOptional) { // -- templateName doesn't exist and is optional templateName = TEMPLATE_DEFAULT; } } /* random */ Random rand = new Random(); if (!RTConfig.hasProperty("random.16")) { RTConfig.setString("random.16", "0x" + StringTools.toHexString(rand.nextInt() & 0xFFFF, 16)); } if (!RTConfig.hasProperty("random.32")) { RTConfig.setString("random.32", "0x" + StringTools.toHexString(rand.nextInt(), 32)); } if (!RTConfig.hasProperty("random.64")) { RTConfig.setString("random.64", "0x" + StringTools.toHexString(rand.nextLong(), 64)); } /* set current time (subject to change) */ String tzStr = RTConfig.getString("timezone", null); TimeZone tz = !StringTools.isBlank(tzStr) ? DateTime.getTimeZone(tzStr) : DateTime.getDefaultTimeZone(); DateTime now = new DateTime(tz); if (!RTConfig.hasProperty("timetamp")) { RTConfig.setLong("timestamp", now.getTimeSec()); } if (!RTConfig.hasProperty("datetime")) { RTConfig.setString("datetime", now.format("yyyy/MM/dd HH:mm:ss z")); } if (!RTConfig.hasProperty("date")) { RTConfig.setString("date", now.format("yyyy/MM/dd")); } if (!RTConfig.hasProperty("time")) { RTConfig.setString("time", now.format("HH:mm:ss")); } if (!RTConfig.hasProperty("timezone")) { RTConfig.setString("timezone", now.format("z")); } /* special case "daysUntil" */ // %{daysUntil=2012:02:20} <== fixed time String ARG_daysUntil_ = "daysUntil"; Set<String> daysUntil_keys = RTConfig.getPropertyKeys(ARG_daysUntil_, false); for (String daysUntil_key : daysUntil_keys) { String daysUntil_key_date = daysUntil_key + ".date"; RTProperties daysUntilRTP = RTConfig.getPropertiesForKey(daysUntil_key, false); if (daysUntilRTP != null) { // -- get/update the RTProperties where "daysUntil" is defined String daysUntil = daysUntilRTP.getString(daysUntil_key, ""); if (StringTools.isBlank(daysUntil)) { // -- remove keys daysUntilRTP.removeProperty(daysUntil_key); daysUntilRTP.removeProperty(daysUntil_key_date); // Print.sysPrintln(daysUntil_key + " ==> <removed>"); // Print.sysPrintln(daysUntil_key_date + " ==> <removed>"); } else if ((daysUntil.indexOf("/") >= 0) || (daysUntil.indexOf(":") >= 0)) { // -- Change "yyyy:mm:dd" to "DD" // Note: The ':' separator should be used instead of '/', because "2010/10/01" is // syntactically correct (ie. division) and can be compiled into a valid value, // while "2010:10:01" is not, and will be caught by the compiler. if (daysUntil.startsWith("'") || daysUntil.startsWith("\"")) { daysUntil = daysUntil.substring(1); // remove prefixing quote } if (daysUntil.endsWith("'") || daysUntil.endsWith("\"")) { daysUntil = daysUntil.substring(0, daysUntil.length() - 1); // remove trailing quote } try { DateTime nowDT = new DateTime(DateTime.getGMTTimeZone()); DateTime futDT = DateTime.parseArgumentDate(daysUntil, null, true); long nowDay = DateTime.getDayNumberFromDate(nowDT); long futDay = DateTime.getDayNumberFromDate(futDT); long deltaD = futDay - nowDay; if (deltaD == 0L) { // -- today deltaD = 1L; // make it tomorrow } else if (deltaD < 0L) { // -- this means that the date has already passed // deltaD = -1L; // already negative } else { deltaD += 1L; // add one more day } daysUntilRTP.setString(daysUntil_key, String.valueOf(deltaD)); daysUntilRTP.setString(daysUntil_key_date, futDT.format(DateTime.DEFAULT_DATE_FORMAT)); } catch (DateTime.DateParseException dpe) { Print.logException("Unable to parse Date: " + daysUntil, dpe); System.exit(1); } // Print.sysPrintln(daysUntil_key + " ==> " + daysUntilRTP.getString(daysUntil_key // ,"?")); // Print.sysPrintln(daysUntil_key_date + " ==> " + // daysUntilRTP.getString(daysUntil_key_date,"?")); } else { long futSec = DateTime.getCurrentTimeSec() + DateTime.DaySeconds(StringTools.parseLong(daysUntil, 0L)); daysUntilRTP.setString( daysUntil_key_date, (new DateTime(futSec)).format(DateTime.DEFAULT_DATE_FORMAT)); // Print.sysPrintln(daysUntil_key + " ==> " + daysUntilRTP.getString(daysUntil_key // ,"?")); // Print.sysPrintln(daysUntil_key_date + " ==> " + // daysUntilRTP.getString(daysUntil_key_date,"?")); } } } /* special case "daysFromNow" */ // %{daysFromNow=30} <== 30 days from now String ARG_daysFromNow_ = "daysFromNow"; Set<String> daysFromNow_keys = RTConfig.getPropertyKeys(ARG_daysFromNow_, false); for (String daysFromNow_key : daysFromNow_keys) { String daysFromNow_key_date = daysFromNow_key + ".date"; RTProperties daysFromNowRTP = RTConfig.getPropertiesForKey(daysFromNow_key, false); if (daysFromNowRTP != null) { // -- get/update the RTProperties where "daysFromNow" is defined String daysFromNow = daysFromNowRTP.getString(daysFromNow_key, ""); if (StringTools.isBlank(daysFromNow)) { // -- remove keys daysFromNowRTP.removeProperty(daysFromNow_key); daysFromNowRTP.removeProperty(daysFromNow_key_date); // Print.sysPrintln(daysFromNow_key + " ==> <removed>"); // Print.sysPrintln(daysFromNow_key_date + " ==> <removed>"); } else { long futSec = DateTime.getCurrentTimeSec() + DateTime.DaySeconds(StringTools.parseLong(daysFromNow, 0L)); daysFromNowRTP.setString(daysFromNow_key, String.valueOf(futSec)); daysFromNowRTP.setString( daysFromNow_key_date, (new DateTime(futSec)).format(DateTime.DEFAULT_DATE_FORMAT)); // Print.sysPrintln(daysFromNow_key + " ==> " + // daysFromNowRTP.getString(daysFromNow_key ,"?")); // Print.sysPrintln(daysFromNow_key_date + " ==> " + // daysFromNowRTP.getString(daysFromNow_key_date,"?")); } } } /* special case "secondsUntil" */ // %{secondsUntil_abc=2012:02:20} <== fixed time // %{secondsUntil_abc=86400} <== relative time (86400 seconds from now) String ARG_secondsUntil_ = "secondsUntil"; Set<String> secUntil_keys = RTConfig.getPropertyKeys(ARG_secondsUntil_, false); for (String secUntil_key : secUntil_keys) { String secUntil_key_date = secUntil_key + ".date"; RTProperties secUntilRTP = RTConfig.getPropertiesForKey(secUntil_key, false); if (secUntilRTP != null) { // -- get/update the RTProperties where "secondsUntil" is defined String secUntil = secUntilRTP.getString(secUntil_key, ""); if (StringTools.isBlank(secUntil)) { // remove keys secUntilRTP.removeProperty(secUntil_key); secUntilRTP.removeProperty(secUntil_key_date); // Print.sysPrintln(secUntil_key + " ==> <removed>"); // Print.sysPrintln(secUntil_key_date + " ==> <removed>"); } else if ((secUntil.indexOf("/") >= 0) || (secUntil.indexOf(":") >= 0)) { // -- Change "yyyy:mm:dd:HH:MM:SS" to "ssssss" // Note: The ':' separator should be used instead of '/', because "2010/10/01" is // syntactically correct (ie. division) and can be compiled into a valid value, // while "2010:10:01" is not, and will be caught by the compiler. if (secUntil.startsWith("'") || secUntil.startsWith("\"")) { secUntil = secUntil.substring(1); // remove prefixing quote } if (secUntil.endsWith("'") || secUntil.endsWith("\"")) { secUntil = secUntil.substring(0, secUntil.length() - 1); // remove trailing quote } try { long nowSec = DateTime.getCurrentTimeSec(); DateTime futDT = DateTime.parseArgumentDate(secUntil, null, true); long futSec = futDT.getTimeSec(); long deltaS = futSec - nowSec; if (deltaS == 0L) { // -- now deltaS = 1L; // make it 1 second from now } else if (deltaS < 0L) { // -- this means that the time has already passed // deltaS = -1L; // already negative } else { deltaS += 1L; // add one more second } secUntilRTP.setString(secUntil_key, String.valueOf(deltaS)); secUntilRTP.setString(secUntil_key_date, futDT.toString()); } catch (DateTime.DateParseException dpe) { Print.logException("Unable to parse Date: " + secUntil, dpe); System.exit(1); } // Print.sysPrintln(secUntil_key + " ==> " + secUntilRTP.getString(secUntil_key // ,"?")); // Print.sysPrintln(secUntil_key_date + " ==> " + // secUntilRTP.getString(secUntil_key_date,"?")); } else { long futSec = DateTime.getCurrentTimeSec() + StringTools.parseLong(secUntil, 0L); secUntilRTP.setString(secUntil_key_date, (new DateTime(futSec)).toString()); // Print.sysPrintln(secUntil_key + " ==> " + secUntilRTP.getString(secUntil_key // ,"?")); // Print.sysPrintln(secUntil_key_date + " ==> " + // secUntilRTP.getString(secUntil_key_date,"?")); } } } /* special case "secondsFromNow" */ // %{secondsFromNow=30} <== 30 seconds from now String ARG_secondsFromNow_ = "secondsFromNow"; Set<String> secondsFromNow_keys = RTConfig.getPropertyKeys(ARG_secondsFromNow_, false); for (String secondsFromNow_key : secondsFromNow_keys) { String secondsFromNow_key_date = secondsFromNow_key + ".date"; RTProperties secondsFromNowRTP = RTConfig.getPropertiesForKey(secondsFromNow_key, false); if (secondsFromNowRTP != null) { // -- get/update the RTProperties where "secondsFromNow" is defined String secondsFromNow = secondsFromNowRTP.getString(secondsFromNow_key, ""); if (StringTools.isBlank(secondsFromNow)) { // -- remove keys secondsFromNowRTP.removeProperty(secondsFromNow_key); secondsFromNowRTP.removeProperty(secondsFromNow_key_date); // Print.sysPrintln(secondsFromNow_key + " ==> <removed>"); // Print.sysPrintln(secondsFromNow_key_date + " ==> <removed>"); } else { long futSec = DateTime.getCurrentTimeSec() + StringTools.parseLong(secondsFromNow, 0L); secondsFromNowRTP.setString(secondsFromNow_key, String.valueOf(futSec)); secondsFromNowRTP.setString( secondsFromNow_key_date, (new DateTime(futSec)).format(DateTime.DEFAULT_DATE_FORMAT)); // Print.sysPrintln(secondsFromNow_key + " ==> " + // secondsFromNowRTP.getString(secondsFromNow_key ,"?")); // Print.sysPrintln(secondsFromNow_key_date + " ==> " + // secondsFromNowRTP.getString(secondsFromNow_key_date,"?")); } } } /* special case "limit" */ String ARG_limit_ = "limit"; Set<String> limit_keys = RTConfig.getPropertyKeys(ARG_limit_, false); for (String limit_key : limit_keys) { RTProperties limitRTP = RTConfig.getPropertiesForKey(limit_key, false); if (limitRTP != null) { String limit = limitRTP.getString(limit_key, ""); if (StringTools.isBlank(limit)) { limitRTP.removeProperty(limit_key); // Print.sysPrintln(limit_key + " ==> <removed>"); } else { // Print.sysPrintln(limit_key + " ==> " + limit); } } } /* adjust packageName */ if (packageName.equals(JAVA_PACKAGE)) { Print.errPrintln( "\nWarning: 'package' argument cannot equal \"package\" (setting to empty string)."); packageName = ""; } // -------------------------------------- /* internal template (single pass only) */ if (StringTools.isBlank(templateName) || templateName.startsWith(TEMPLATE_)) { try { // -- input source String inputSource = standardTemplate(templateName, packageName); if (StringTools.isBlank(inputSource)) { if (isOptional) { // -- optional "templateName" not defined, use default template inputSource = standardTemplate(null, packageName); // non-blank } else { throw new IOException("Standard template not found: " + templateName); } } // -- write template output File outputFile = CompiletimeVars.getOutputFile(directory, outputName, overwrite); CompiletimeVars.writeOutputSource(inputSource, outputFile); } catch (NoOverwriteException noe) { // -- outputFile exists, quietly ignore Print.sysPrintln(noe.getMessage()); System.exit(0); } catch (IOException ioe) { // -- error writin file Print.errPrintln("\nError writing template: " + ioe.getMessage()); System.exit(1); } System.exit(0); } // -------------------------------------- /* get input file(s) */ File inputFileArray[] = null; if (templateName.startsWith("**/*.")) { // -- all files, in all directories (recursive) String fileGlob = templateName.substring(3); File files[] = FileTools.getFiles(directory, fileGlob, true); inputFileArray = files; } else if (templateName.startsWith("*.")) { // -- all files in specified directory String fileGlob = templateName; File files[] = FileTools.getFiles(directory, fileGlob, false); inputFileArray = files; } else { // -- single specific file File file = (directory != null) ? new File(directory, templateName) : new File(templateName); inputFileArray = new File[] {file}; } /* loop through input files */ boolean singlePass = false; for (File inputFile : inputFileArray) { /* file must exist here */ if (!inputFile.isFile()) { // -- not a file continue; } /* get input source from template file */ String inputSource = CompiletimeVars.readTemplate(inputFile, packageName); if (StringTools.isBlank(inputSource)) { // -- inputSource not available? continue; } /* precheck output file */ File outputFile = null; try { if (StringTools.isBlank(outputName) || outputName.equalsIgnoreCase("stdout")) { // -- output to stdout (multi-pass ok) } else if (outputName.equalsIgnoreCase("inline")) { // -- write back to template file (multi-pass ok) overwrite = true; // assume implied overwrite outputFile = inputFile; } else { // -- output to specified file (single-pass only) outputFile = getOutputFile(directory, outputName, overwrite); singlePass = true; } } catch (NoOverwriteException noe) { // -- outputFile exists, quietly ignore Print.sysPrintln(noe.getMessage()); System.exit(0); } catch (IOException ioe) { Print.errPrintln("\nInvalid output file: " + ioe.getMessage()); System.exit(1); } /* adjust source and write output */ try { CompiletimeVars.writeOutputSource(inputSource, outputFile); if (singlePass) { break; } } catch (IOException ioe) { Print.errPrintln("\nError writing file: " + ioe.getMessage()); System.exit(1); } } /* success */ System.exit(0); }
/* write mapping support JS to stream */ protected void writeJSVariables(PrintWriter out, RequestProperties reqState) throws IOException { // This var initilizations must not use any functions defined in 'jsmap.js' PrivateLabel privLabel = reqState.getPrivateLabel(); I18N i18n = privLabel.getI18N(JSMap.class); Locale locale = reqState.getLocale(); GeoPoint dftCenter = this.getDefaultCenter(null); boolean isFleet = reqState.isFleet(); Account account = reqState.getCurrentAccount(); long maxPushpins = this.getMaxPushpins(reqState); out.write("// --- Map support Javascript [" + this.getName() + "]\n"); JavaScriptTools.writeJSVar(out, "MAP_PROVIDER_NAME", this.getName()); /* properties */ boolean wrotePropHeader = false; RTProperties rtp = this.getProperties(); for (Iterator<?> i = rtp.keyIterator(); i.hasNext(); ) { Object key = i.next(); if (!this._skipPropKey(key)) { if (!wrotePropHeader) { // out.write("\n"); out.write("// Defined properties\n"); wrotePropHeader = true; } String val[] = StringTools.parseStringArray(rtp.getProperty(key, "").toString(), '\n'); String propVar = "PROP_" + key.toString().replace('.', '_').replace('-', '_'); if (val.length == 1) { if (StringTools.isDouble(val[0], true) || StringTools.isLong(val[0], true) || StringTools.isBoolean(val[0], true)) { JavaScriptTools.writeJSVar(out, propVar, val[0], false); } else { JavaScriptTools.writeJSVar(out, propVar, val[0]); } } else if (val.length > 1) { JavaScriptTools.writeJSVar(out, propVar, StringTools.join(val, "\\n")); } } } /* speed units */ Account.SpeedUnits speedUnits = reqState.getSpeedUnits(); boolean speedIsKph = speedUnits.equals(Account.SpeedUnits.KPH); double altUnitsMult = speedIsKph ? 1.0 : GeoPoint.FEET_PER_METER; String altUnitsName = speedIsKph ? i18n.getString("JSMap.altitude.meters", "Meters") : i18n.getString("JSMap.altitude.feet", "Feet"); /* constants (these do not change during the user session) */ out.write("// Element IDs\n"); JavaScriptTools.writeJSVar(out, "MAP_ID", this.getMapID()); JavaScriptTools.writeJSVar(out, "ID_DETAIL_TABLE", ID_DETAIL_TABLE); JavaScriptTools.writeJSVar(out, "ID_DETAIL_CONTROL", ID_DETAIL_CONTROL); JavaScriptTools.writeJSVar(out, "ID_LAT_LON_DISPLAY", ID_LAT_LON_DISPLAY); JavaScriptTools.writeJSVar(out, "ID_DISTANCE_DISPLAY", ID_DISTANCE_DISPLAY); JavaScriptTools.writeJSVar(out, "ID_LATEST_EVENT_DATE", ID_LATEST_EVENT_DATE); JavaScriptTools.writeJSVar(out, "ID_LATEST_EVENT_TIME", ID_LATEST_EVENT_TIME); JavaScriptTools.writeJSVar(out, "ID_LATEST_EVENT_TMZ", ID_LATEST_EVENT_TMZ); JavaScriptTools.writeJSVar(out, "ID_LATEST_BATTERY", ID_LATEST_BATTERY); JavaScriptTools.writeJSVar(out, "ID_MESSAGE_TEXT", ID_MESSAGE_TEXT); out.write("// Geozone IDs\n"); JavaScriptTools.writeJSVar(out, "ID_ZONE_LATITUDE_", ID_ZONE_LATITUDE_); JavaScriptTools.writeJSVar(out, "ID_ZONE_LONGITUDE_", ID_ZONE_LONGITUDE_); JavaScriptTools.writeJSVar(out, "ID_ZONE_RADIUS_M", ID_ZONE_RADIUS_M); out.write("// Session constants\n"); JavaScriptTools.writeJSVar(out, "PUSHPINS_SHOW", rtp.getBoolean(PROP_map_pushpins, true)); JavaScriptTools.writeJSVar(out, "MAX_PUSH_PINS", maxPushpins); JavaScriptTools.writeJSVar(out, "MAX_CREATION_AGE_SEC", rtp.getInt(PROP_map_maxCreationAge, 0)); JavaScriptTools.writeJSVar(out, "MAP_WIDTH", this.getDimension().getWidth()); JavaScriptTools.writeJSVar(out, "MAP_HEIGHT", this.getDimension().getHeight()); JavaScriptTools.writeJSVar(out, "IS_FLEET", isFleet); JavaScriptTools.writeJSVar( out, "SHOW_SAT_COUNT", rtp.getBoolean(PROP_detail_showSatCount, false)); JavaScriptTools.writeJSVar(out, "SHOW_SPEED", rtp.getBoolean(PROP_info_showSpeed, true)); JavaScriptTools.writeJSVar( out, "COMBINE_SPEED_HEAD", rtp.getBoolean(PROP_combineSpeedHeading, true)); JavaScriptTools.writeJSVar(out, "SHOW_ALTITUDE", rtp.getBoolean(PROP_info_showAltitude, false)); JavaScriptTools.writeJSVar(out, "SHOW_ADDR", reqState.getShowAddress()); JavaScriptTools.writeJSVar( out, "INCL_BLANK_ADDR", rtp.getBoolean(PROP_info_inclBlankAddress, true)); JavaScriptTools.writeJSVar( out, "SHOW_OPT_FIELDS", rtp.getBoolean(PROP_info_showOptionalFields, true)); JavaScriptTools.writeJSVar( out, "INCL_BLANK_OPT_FIELDS", rtp.getBoolean(PROP_info_inclBlankOptFields, true)); JavaScriptTools.writeJSVar( out, "LATLON_FORMAT", Account.getLatLonFormat(account).getIntValue()); JavaScriptTools.writeJSVar( out, "DISTANCE_KM_MULT", reqState.getDistanceUnits().getMultiplier()); JavaScriptTools.writeJSVar(out, "SPEED_KPH_MULT", speedUnits.getMultiplier()); JavaScriptTools.writeJSVar(out, "SPEED_UNITS", speedUnits.toString(locale)); JavaScriptTools.writeJSVar(out, "ALTITUDE_METERS_MULT", altUnitsMult); JavaScriptTools.writeJSVar(out, "ALTITUDE_UNITS", altUnitsName); JavaScriptTools.writeJSVar(out, "TIME_ZONE", reqState.getTimeZoneString(null)); // long JavaScriptTools.writeJSVar( out, "DEFAULT_CENTER", "{ lat:" + dftCenter.getLatitude() + ", lon:" + dftCenter.getLongitude() + " }", false); JavaScriptTools.writeJSVar(out, "DEFAULT_ZOOM", this.getDefaultZoom(JSMap.DEFAULT_ZOOM, false)); JavaScriptTools.writeJSVar(out, "PUSHPIN_ZOOM", this.getDefaultZoom(JSMap.PUSHPIN_ZOOM, true)); JavaScriptTools.writeJSVar(out, "MAP_AUTHORIZATION", this.getAuthorization()); JavaScriptTools.writeJSVar( out, "SCROLL_WHEEL_ZOOM", rtp.getBoolean(PROP_scrollWheelZoom, false)); JavaScriptTools.writeJSVar(out, "DEFAULT_VIEW", rtp.getString(PROP_map_view, "").toLowerCase()); JavaScriptTools.writeJSVar(out, "ROUTE_LINE_SHOW", rtp.getBoolean(PROP_map_routeLine, true)); JavaScriptTools.writeJSVar( out, "ROUTE_LINE_COLOR", rtp.getString(PROP_map_routeLine_color, "#FF2222")); JavaScriptTools.writeJSVar( out, "ROUTE_LINE_ARROWS", rtp.getBoolean(PROP_map_routeLine_arrows, false)); JavaScriptTools.writeJSVar( out, "ROUTE_SNAP_TO_ROAD", rtp.getBoolean(PROP_map_routeLine_snapToRoad, false)); // Google V2 only JavaScriptTools.writeJSVar(out, "REPLAY_INTERVAL", this.getReplayInterval()); JavaScriptTools.writeJSVar(out, "REPLAY_SINGLE", this.getReplaySinglePushpin()); /* address title */ String adrTitles[] = reqState.getAddressTitles(); String adrTitle = ListTools.itemAt(adrTitles, 0, null); /* device title */ String devTitles[] = reqState.getDeviceTitles(); String devTitle = ListTools.itemAt(devTitles, 0, null); /* labels */ out.write("// Localized Text/Labels\n"); JavaScriptTools.writeJSVar( out, "HEADING", "new Array(" + "\"" + GeoPoint.CompassHeading.N.toString(locale) + "\"," + "\"" + GeoPoint.CompassHeading.NE.toString(locale) + "\"," + "\"" + GeoPoint.CompassHeading.E.toString(locale) + "\"," + "\"" + GeoPoint.CompassHeading.SE.toString(locale) + "\"," + "\"" + GeoPoint.CompassHeading.S.toString(locale) + "\"," + "\"" + GeoPoint.CompassHeading.SW.toString(locale) + "\"," + "\"" + GeoPoint.CompassHeading.W.toString(locale) + "\"," + "\"" + GeoPoint.CompassHeading.NW.toString(locale) + "\")", false); JavaScriptTools.writeJSVar(out, "TEXT_INFO_DATE", i18n.getString("JSMap.info.date", "Date")); JavaScriptTools.writeJSVar(out, "TEXT_INFO_GPS", i18n.getString("JSMap.info.gps", "GPS")); JavaScriptTools.writeJSVar(out, "TEXT_INFO_SATS", i18n.getString("JSMap.info.sats", "#Sats")); JavaScriptTools.writeJSVar(out, "TEXT_INFO_SPEED", i18n.getString("JSMap.info.speed", "Speed")); JavaScriptTools.writeJSVar(out, "TEXT_INFO_HEADING", GeoPoint.GetHeadingTitle(locale)); JavaScriptTools.writeJSVar( out, "TEXT_INFO_ALTITUDE", i18n.getString("JSMap.info.altitude", "Altitude")); JavaScriptTools.writeJSVar( out, "TEXT_INFO_STOP_TIME", i18n.getString("JSMap.info.stopTime", "Stop Time")); JavaScriptTools.writeJSVar( out, "TEXT_INFO_ADDR", !StringTools.isBlank(adrTitle) ? adrTitle : i18n.getString("JSMap.info.address", "Address")); JavaScriptTools.writeJSVar( out, "TEXT_DEVICE", !StringTools.isBlank(devTitle) ? devTitle : i18n.getString("JSMap.device", "Device")); JavaScriptTools.writeJSVar(out, "TEXT_DATE", i18n.getString("JSMap.dateTime", "Date/Time")); JavaScriptTools.writeJSVar(out, "TEXT_CODE", i18n.getString("JSMap.code", "Status")); JavaScriptTools.writeJSVar(out, "TEXT_LATLON", i18n.getString("JSMap.latLon", "Lat/Lon")); JavaScriptTools.writeJSVar(out, "TEXT_SATCOUNT", i18n.getString("JSMap.satCount", "#Sats")); JavaScriptTools.writeJSVar( out, "TEXT_ADDR", !StringTools.isBlank(adrTitle) ? adrTitle : i18n.getString("JSMap.address", "Address")); JavaScriptTools.writeJSVar(out, "TEXT_SPEED", reqState.getSpeedUnits().toString(locale)); JavaScriptTools.writeJSVar(out, "TEXT_HEADING", i18n.getString("JSMap.heading", "Heading")); JavaScriptTools.writeJSVar(out, "TEXT_DISTANCE", reqState.getDistanceUnits().toString(locale)); JavaScriptTools.writeJSVar( out, "TEXT_TIMEOUT", i18n.getString("JSMap.sessionTimeout", "Your session has timed-out.\nPlease login ...")); JavaScriptTools.writeJSVar( out, "TEXT_PING_OK", i18n.getString( "JSMap.pingDevice.ok", "A command request has been sent.\nThe {0} should respond shortly ...", devTitles)); JavaScriptTools.writeJSVar( out, "TEXT_PING_ERROR", i18n.getString( "JSMap.pingDevice.err", "The command request failed.\nThe {0} may not support this feature ...", devTitles)); JavaScriptTools.writeJSVar( out, "TEXT_MAXPUSHPINS_ALERT", i18n.getString( "JSMap.maxPushpins.err", "The maximum number of allowed pushpins has been exceeded.\n" + " [max={0}] Not all pushpins may be displayed on this map.\n" + "Adjust the 'From' time to see remaining pushpins", String.valueOf(maxPushpins))); JavaScriptTools.writeJSVar( out, "TEXT_MAXPUSHPINS_MSG", i18n.getString( "JSMap.maxPushpins.msg", "Only partial data displayed. The maximum allowed pushpins has been reached.<BR>" + "Adjust the Date/Time range accordingly to view the remaining pushpins.")); JavaScriptTools.writeJSVar( out, "TEXT_UNAVAILABLE", i18n.getString("JSMap.unavailable", "unavailable")); JavaScriptTools.writeJSVar( out, "TEXT_showLocationDetails", i18n.getString("JSMap.showLocationDetails", "Show Location Details")); JavaScriptTools.writeJSVar( out, "TEXT_hideLocationDetails", i18n.getString("JSMap.hideLocationDetails", "Hide Location Details")); /* map "Loading ..." */ JavaScriptTools.writeJSVar( out, "TEXT_LOADING_MAP_POINTS", (rtp.getBoolean(PROP_MAP_LOADING, false) ? i18n.getString("JSMap.loadingMapPoints", "Loading Map Points ...") : null)); JavaScriptTools.writeJSVar( out, "MAP_LOADING_IMAGE_URI", rtp.getString(PROP_MAP_LOADING_IMAGE, null)); /* icons/shadows */ JSMap.writePushpinArray(out, reqState); /* constants (these do not change during the user session) */ out.write("// Geozone support constants\n"); JavaScriptTools.writeJSVar(out, "jsvGeozoneMode", false); JavaScriptTools.writeJSVar(out, "MAX_ZONE_RADIUS_M", Geozone.MAX_RADIUS_METERS); JavaScriptTools.writeJSVar(out, "MIN_ZONE_RADIUS_M", Geozone.MIN_RADIUS_METERS); JavaScriptTools.writeJSVar( out, "DETAIL_REPORT", this.isFeatureSupported(FEATURE_DETAIL_REPORT)); JavaScriptTools.writeJSVar( out, "DETAIL_INFO_BOX", this.isFeatureSupported(FEATURE_DETAIL_INFO_BOX)); JavaScriptTools.writeJSVar(out, "TEXT_METERS", GeoPoint.DistanceUnits.METERS.toString(locale)); /* variables */ out.write("// TrackMap Vars\n"); JavaScriptTools.writeJSVar(out, "jsvPoiPins", null); JavaScriptTools.writeJSVar(out, "jsvDataSets", null); JavaScriptTools.writeJSVar(out, "jsvDetailPoints", null); JavaScriptTools.writeJSVar(out, "jsvDetailVisible", false); JavaScriptTools.writeJSVar( out, "jsvDetailAscending", privLabel.getBooleanProperty(PrivateLabel.PROP_TrackMap_detailAscending, true)); JavaScriptTools.writeJSVar( out, "jsvDetailCenterPushpin", privLabel.getBooleanProperty(PrivateLabel.PROP_TrackMap_detailCenterPushpin, false)); /* last update time */ TimeZone tmz = reqState.getTimeZone(); String dateFmt = (account != null) ? account.getDateFormat() : BasicPrivateLabel.getDefaultDateFormat(); String timeFmt = (account != null) ? account.getTimeFormat() : BasicPrivateLabel.getDefaultTimeFormat(); DateTime today = new DateTime(tmz); JavaScriptTools.writeJSVar(out, "jsvTodayEpoch", today.getTimeSec()); JavaScriptTools.writeJSVar( out, "jsvTodayYMD", "{ YYYY:" + today.getYear(tmz) + ", MM:" + today.getMonth1(tmz) + ", DD:" + today.getDayOfMonth(tmz) + " }", false); JavaScriptTools.writeJSVar(out, "jsvTodayDateFmt", today.format(dateFmt, tmz)); JavaScriptTools.writeJSVar(out, "jsvTodayTimeFmt", today.format(timeFmt, tmz)); JavaScriptTools.writeJSVar(out, "jsvTodayTmzFmt", today.format("z", tmz)); /* last event time */ out.write("// Last event time\n"); DateTime lastEventTime = reqState.getLastEventTime(); if (lastEventTime != null) { JavaScriptTools.writeJSVar(out, "jsvLastEventEpoch", lastEventTime.getTimeSec()); JavaScriptTools.writeJSVar( out, "jsvLastEventYMD", "{ YYYY:" + lastEventTime.getYear(tmz) + ", MM:" + lastEventTime.getMonth1(tmz) + ", DD:" + lastEventTime.getDayOfMonth(tmz) + " }", false); JavaScriptTools.writeJSVar(out, "jsvLastEventDateFmt", lastEventTime.format(dateFmt, tmz)); JavaScriptTools.writeJSVar(out, "jsvLastEventTimeFmt", lastEventTime.format(timeFmt, tmz)); JavaScriptTools.writeJSVar(out, "jsvLastEventTmzFmt", lastEventTime.format("z", tmz)); JavaScriptTools.writeJSVar(out, "jsvLastBatteryLevel", 0L); JavaScriptTools.writeJSVar(out, "jsvLastSignalStrength", 0L); } else { JavaScriptTools.writeJSVar(out, "jsvLastEventEpoch", 0L); JavaScriptTools.writeJSVar(out, "jsvLastEventYMD", null); JavaScriptTools.writeJSVar(out, "jsvLastEventDateFmt", null); JavaScriptTools.writeJSVar(out, "jsvLastEventTimeFmt", null); JavaScriptTools.writeJSVar(out, "jsvLastEventTmzFmt", null); JavaScriptTools.writeJSVar(out, "jsvLastBatteryLevel", 0.0); JavaScriptTools.writeJSVar(out, "jsvLastSignalStrength", 0.0); } /* map pointers */ out.write("// Map vars\n"); JavaScriptTools.writeJSVar(out, "jsmapElem", null); JavaScriptTools.writeJSVar(out, "jsmap", null); }