Welcome to the Cumulus Support forum.

Latest Cumulus MX V3 release 3.28.6 (build 3283) - 21 March 2024

Cumulus MX V4 beta test release 4.0.0 (build 4017) - 17 March 2024

Legacy Cumulus 1 release v1.9.4 (build 1099) - 28 November 2014 (a patch is available for 1.9.4 build 1099 that extends the date range of drop-down menus to 2030)

Download the Software (Cumulus MX / Cumulus 1 and other related items) from the Wiki

New quake-json.php script replaces quake-USA/quake-World

Discussion of Ken True's web site templates

Moderator: saratogaWX

Post Reply
User avatar
saratogaWX
Posts: 1170
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

New quake-json.php script replaces quake-USA/quake-World

Post by saratogaWX »

The USGS has been busy updating their website with map technology and is in the process of shutting down several pages that are used for earthquake information by some of my scripts -- so, the following scripts are now deprecated (and will work until the USGS shuts down their source pages):

quake-CANV.php (California/Nevada specific quakes)
quake-USA.php (United States and territories)
quake-WORLD.php (non-USA locations)
quake-WORLD-ML.php (non-USA locations with translation capability)

The USGS now has a GeoJSON feed for all earthquakes over the last 7 days that reports magnitude 1.0+ (USA/Territories) and 4.0+ (non-USA) and I've created a new quake-json.php script to work with the new feed. As a bonus, there's now an automatic Google Map (V3) for display by the script, and since it's a V3 map, you don't need to request a Google Map Key to have it work for you :)

The table of earthquakes is now sortable by magnitude, distance from station, and time with just a click on the column header (if JavaScript is enabled in the browser).

For standalone and tinkerers, I suggest using the script instructions and download the .zip package (includes graphics for the Google Map).

For AJAX/PHP template users, the Base-USA and Base-World templates have been updated so the update tool page with a query of 8-Sep-2012 will get you what you need.

For Base-World template users, you'll need to add some entries to your language-LL.txt translation files to achieve full translation from English for the new wxquake.php page. Note: the |of| entry below is used in the reports for quake location as in:
20 mi NNW of Saratoga, California

Code: Select all

langlookup|Update time|Update time|
langlookup|of|of|
langlookup|No earthquakes of magnitude|No earthquakes of magnitude|
langlookup|or greater within|or greater within|
langlookup|reported in last 7 days|reported in last 7 days|
langlookup|Cluster - click to expand details|Cluster - click to expand details|
langlookup|Enable JavaScript to view the Google Map.|Enable JavaScript to view the Google Map.|
langlookup|Earthquakes in the past 7 days of magnitude|Earthquakes in the past 7 days of magnitude|
langlookup|or greater within|or greater within|
langlookup|Epicenter Near|Epicenter Near|
langlookup|Magnitude|Magnitude|
langlookup|Distance to Epicenter|Distance to Epicenter|
langlookup|Local Time|Local Time|
langlookup|Link|Link|
langlookup|map|map|
langlookup|Note: Click on column heading marked with|Note: Click on column heading marked with|
langlookup|to sort column contents.|to sort column contents.|
langlookup|earthquakes found. Click on location or map links for more details from the <a href="http://earthquake.usgs.gov/earthquakes/map/">USGS</a>|earthquakes found. Click on location or map links for more details from the <a href="http://earthquake.usgs.gov/earthquakes/map/">USGS</a>|
langlookup|Depth|Depth|
langlookup|Distance to epicenter|Distance to epicenter|
langlookup|Map and data courtesy of|Map and data courtesy of|
langlookup|United States Geological Survey|United States Geological Survey|
I'd appreciate it if folks doing the translations would send me their translation so I could add it to the Base-World languages set .. Thanks in advance!

Enjoy!

Best regards,
Ken

Sample of script output:

Image
gemini06720
Posts: 1700
Joined: Mon 10 Aug 2009 10:16 pm
Weather Station: No weather station
Operating System: No operating system
Location: World...

Re: New quake-json.php script replaces quake-USA/quake-World

Post by gemini06720 »

Nice work, again, as usual, Ken... :)

After cleaning up the code, the script worked (as expected from your scripts) and displayed the earthquakes for my area - I might not need the canadian earthquakes script anymore... ;)
User avatar
saratogaWX
Posts: 1170
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: New quake-json.php script replaces quake-USA/quake-World

Post by saratogaWX »

Hi Ray,
Thanks for the kind words. I'd be interested to see what you'd cleaned up so I could possibly improve what was released.
You can send it .zipped to my email (I think you still have that).

Best regards,
Ken
User avatar
saratogaWX
Posts: 1170
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: New quake-json.php script replaces quake-USA/quake-World

Post by saratogaWX »

Did a minor update to fix XHTML 1.0-Strict validation of script and remove pesky ' GMT' from the local time display (9-Sep-2012)

Best regards,
Ken
gemini06720
Posts: 1700
Joined: Mon 10 Aug 2009 10:16 pm
Weather Station: No weather station
Operating System: No operating system
Location: World...

Re: New quake-json.php script replaces quake-USA/quake-World

Post by gemini06720 »

Ken, I have been slowly adapting your scripts to HTML5 (almost all - at least those I can test and use within North America).

I still need to make a few additional modifications before I can process both the 'quake-json.php' and the 'wxquake-json.php' (and the 'quakes.php') scripts through the validation services.

The first cleanup I do on all your scripts (and that one is quick) it to replace all tab characters with two spaces - it then allows me to properly indent, not only the code in the PHP script, but also the source code of the displayed web page - this 'contempt/disdain' of the tab character has been with me since my early days with the Commodore 64 and the programming techniques I received at the UoM (University of Montréal)... :roll:

The second cleanup I do (and that one can be longer, sometimes very long) and that I ensure that there are no missing curly brackets (ie: {}) and that the line are properly indented.

Once those two operations (my cleanups) have been performed, then I can see better (or more clearly) where I am going, what the code is doing, how/when/where it is doing it - hey, a guy needs to 'exercise' that 'big lump of gray matter up there' and there is no better way than continued learning... :mrgreen:

The scripts that can be used as standalone are then being upgraded to HTML5.

Once I am satisfied with the results, as I wrote above, the scripts are then tested through the W3C Markup Validation Service and the W3C CSS Validation Service.

Oh, should you be interested in having a quick look at my 'still-in-needs-to-be-further-tested' version of the script, it can be seen on the North American Earthquakes within 500 kmpage.
Did a minor update to fix XHTML 1.0-Strict validation of script and remove pesky ' GMT' from the local time display
I have not yet validated either scripts so I have not encountered the first minor problem.

Since I 'break' down the date format into two variables (a '$timeOnlyFormat' and a '$dateOnlyFormat' - I find the default '$timeFormat' too limited when used in a multilingual environment), I cannot remember seeing the 'GMT' in the local time display.
User avatar
nitrx
Posts: 1297
Joined: Sun 13 Dec 2009 1:21 pm
Weather Station: WH1080
Operating System: Windows 10
Location: Apeldoorn The Netherlands
Contact:

Re: New quake-json.php script replaces quake-USA/quake-World

Post by nitrx »

Ken thanks for the quake-update

A translation to Dutch / Flemish language ( The Netherlands and part of Belgium )

Code: Select all

langlookup|Update time|Update tijd|
langlookup|of|van|
langlookup|No earthquakes of magnitude|Geen aardbevingen met magnitude|
langlookup|or greater within|of groter binnen|
langlookup|reported in last 7 days|gerapporteerd in laaste week|
langlookup|Cluster - click to expand details|Cluster - klik om details te zien|
langlookup|Enable JavaScript to view the Google Map.|Javascript moet aanstaan om Google Map te zien.|
langlookup|Earthquakes in the past 7 days of magnitude|Aardbevingen afgelopen week met magnitude|
langlookup|or greater within|of groter binnen|
langlookup|Epicenter Near|Epicentrum bij|
langlookup|Magnitude|Magnitude|
langlookup|Distance to Epicenter|Afstand tot epicentrum|
langlookup|Local Time|Lokale tijd|
langlookup|Link|Link|
langlookup|map|kaart|
langlookup|Note: Click on column heading marked with|Opmerking: Klik op de kolomkop gemarkeerd met|
langlookup|to sort column contents.|om de inhoud van de kolom te sorteren.|
langlookup|earthquakes found. Click on location or map links for more details from the <a href="http://earthquake.usgs.gov/earthquakes/map/">USGS</a>|aardbevingen gevonden. Klik op loktie of kaart links voor meer details van de <a href="http://earthquake.usgs.gov/earthquakes/map/">USGS</a>|
langlookup|Depth|Diepte|
langlookup|Distance to epicenter|Afstand tot epicentrum|
langlookup|Map and data courtesy of|Kaart en data met toestemming van|
langlookup|United States Geological Survey|United States Geological Survey|
User avatar
saratogaWX
Posts: 1170
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: New quake-json.php script replaces quake-USA/quake-World

Post by saratogaWX »

Hi Ron,

Thanks for the Dutch translations :)

Ray,
I've taken a look at your wxquake-json.php code (the work in progress on your site).
I see you've established a Date and a Time column separately .. you'll need to work a bit to have the columns sort correctly as now they do not.
I'd recommend you change

Code: Select all

        <td><?php echo $dText; ?></td>
        <td><?php echo $QDateDate; ?></td>
        <td><?php echo $QDateTime; ?></td>
to

Code: Select all

        <td><span style=\"display:none\">$distKsort</span><?php echo $dText; ?></td>
        <td><span style=\"display: none\">$Qtimestamp</span><?php echo $QDateDate; ?></td>
        <td><span style=\"display: none\">$Qtimestamp</span><?php echo $QDateTime; ?></td>
and change

Code: Select all

    $distanceK = round(distance($myLat,$myLong,$latitude,$longitude,"K"));
to

Code: Select all

    $distanceK = round(distance($myLat,$myLong,$latitude,$longitude,"K"));
	  $distKsort = sprintf("%06d",$distanceK); // make an alpha sort key
this will allow the sorttable.js script to correctly sort the distance, date and time columns using the hidden values instead of the formatted values AND be fully HTML validated. I'd done that in the V1.01 of the script.

I do wonder about your adding the stock template GNU text to the top of the quake-json.php
##############################################################################################
# Cumulus/Weather Display - Canada Multilingual Template Set
##############################################################################################
#
# Project: Canada Multilingual Weather Templates
# Module: quake-json.php
# Purpose: Earthquakes
# Authors: Kevin W. Reed <tnet.com>
# Ken True <saratoga-weather.org>
# Ray Beriau <tzouhalem.net>
#
# Copyright: (c) 1992-2007 TNET Services, Inc.
# Copyright: (c) 1992-2012 Saratoga-Weather
# Copyright: (c) 2006-2012 Tzouhalem-Maple Bay
#
##############################################################################################
as this script was not authored by Kevin (only the original included-site design parts of the template were his), and the back-dates for the additional copyrights are a bit strange as this script was entirely written this year. Since you're not redistributing the scripts, I suppose you can have what you like there .. if you decide to redistribute, then I think the correction is in order.

Regarding your preferences for reformatting the whitespace to make it more readable for you, that is your prerogative .. I personally would not call that 'clean up', but 'beautifying' .. the term 'clean up' usually implies using shorter, more elegant algorithms or code logic restructuring to allow faster execution. I also noticed you've applied your preference for having subdirectories used for CSS and JavaScript.

Best regards,
Ken
User avatar
saratogaWX
Posts: 1170
Joined: Wed 06 May 2009 5:02 am
Weather Station: Davis Vantage Pro Plus
Operating System: Windows 10 Professional
Location: Saratoga, CA, USA
Contact:

Re: New quake-json.php script replaces quake-USA/quake-World

Post by saratogaWX »

Latest update to the quake-json.php (V1.02) and for template users, wxquake.php adds these features:
1) a new $setDoLinkTarget parameter before the include("quake-json.php") that controls opening the links in a new page in both the table and the popup windows
2) support for translation of Google Map controls (when run with the AJAX/PHP template set)
3) improved diagnostics for getting the GeoJSON feed from the USGS
4) a ?cache=no argument to force a cache refresh

Standalone script users: http://saratoga-weather.org/scripts-quake.php for the download

V3 template users: http://saratoga-weather.org/wxtemplates/updates.php for 12-Sep-2012 query
The Base-World update includes the Danish, Dutch, Greek, Italian, and Norwegian translation updates to support the
wxquake.php display.

Best regards,
Ken
Hunter362
Posts: 93
Joined: Tue 19 Oct 2010 12:20 am
Weather Station: Ambient Weather WS-2080
Operating System: Ubuntu 14.4
Location: Fairmount, New York (USA)
Contact:

Re: New quake-json.php script replaces quake-USA/quake-World

Post by Hunter362 »

I installed the new script and for whatever reason the Google map image doesn't display on my site.
The only mods I had made was to distance, and my Lat & Long entries.
So I copied the original back in place with *no* mods and still the Google map doesn't display.
Any ideas?
View it at http://weather.cerchia.com/ajax/wxquake_new.php

Update
While browsing the wxfourm.net I saw a post from Ken, to try and remove the leading "0" from your Longitude, ex: -076 to -76
and there you go... I got the map!!

Thanks Ken!

Bill
Post Reply