Skip to content

Commit

Permalink
redisigned for xml parser
Browse files Browse the repository at this point in the history
  • Loading branch information
vasvlad committed Jul 12, 2013
1 parent 5161d78 commit 4908b7e
Show file tree
Hide file tree
Showing 9 changed files with 226 additions and 15 deletions.
84 changes: 84 additions & 0 deletions omweather-hko-gov-hk-stations-db/examples/englishwx2.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@

<HTML lang="zh-hk" >
<HEAD>
<TITLE>Current Weather</TITLE>
<META http-equiv="Content-Type" content="text/html; CHARSET=Big5-HKSCS">
<meta name="Comments" content="WCAG2.0_Verified" />
<meta name="Description" content="Current Weather" />
<meta name="Keywords" content="Current Weather" />

</HEAD>
<BODY bgcolor="#FFFFFF">
<script type="text/javascript" src="/js/jquery/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="/js/clf_textonly.js"></script>
<style type="text/css">
#wcag_logo_area{
display:inline;
text-align: center;
}
#wcag_logo_area a img{
border: 0px;
position:relative;
top:12px;
}
</style>
<link rel="SHORTCUT ICON" href="/Logo.ico">
<p align="center"><img src="../../images_e/logo_dblue.gif" alt="Hong Kong Observatory Logo" width="333" height="65"></p>
<h1 align="center">Current Weather</h1><p>
<span style="font-style:italic;">Bulletin updated at 09:02 HKT 12/Jul/2013</span>
</p>
<!--Current Weather-->
<pre>
At 9 a.m. at Hong Kong Observatory :
Air Temperature : 28 degrees Celsius
Relative Humidity : 82 per cent
Weather Cartoon : No. 50 - SUNNY

During the past hour the mean UV Index recorded at King's Park : 3
Intensity of UV radiation : moderate

Please be reminded that:

The Very Hot Weather Warning is now in force. Hot weather
might cause adverse health effects. Members of the public
should take care to avoid heatstroke.



The air temperatures at other places were:

King's Park 29 degrees;
Wong Chuk Hang 30 degrees;
Ta Kwu Ling 30 degrees;
Lau Fau Shan 29 degrees;
Tai Po 29 degrees;
Sha Tin 30 degrees;
Tuen Mun 31 degrees;
Tseung Kwan O 30 degrees;
Sai Kung 31 degrees;
Cheung Chau 29 degrees;
Chek Lap Kok 30 degrees;
Tsing Yi 29 degrees;
Shek Kong 30 degrees;
Tsuen Wan Ho Koon 28 degrees;
Tsuen Wan Shing Mun Valley 30 degrees;
Hong Kong Park 29 degrees;
Shau Kei Wan 30 degrees;
Kowloon City 31 degrees;
Happy Valley 31 degrees;
Wong Tai Sin 31 degrees;
Stanley 30 degrees;
Kwun Tong 30 degrees;
Sham Shui Po 30 degrees.

Between midnight and 9 a.m. the minimum temperature was 27.5
degrees Celsius at the Hong Kong Observatory.

</pre>
<!--/Current Weather-->
<hr>
| <a href="../readme.htm">Copyright and Disclaimer</a> | <a href="../index.htm">Home</a> |
<a href="chinesewx2.htm">Chinese Version / ¤¤¤åª©¥»</a> | <a href="http://rss.weather.gov.hk/rss/CurrentWeather.xml"><img src="/img/rss3.gif" alt="Current Weather Report RSS" border="0"/></a> | <br><div id="wcag_logo_area"></div>
<link rel="alternate" type="application/rss+xml" title="Current Weather Report" href="http://rss.weather.gov.hk/rss/CurrentWeather.xml">
</BODY>
</HTML>
111 changes: 111 additions & 0 deletions omweather-hko-gov-hk-stations-db/examples/nday.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@

<HTML lang="zh-hk" >
<HEAD>
<TITLE>7-day Weather Forecast</TITLE>
<META http-equiv="Content-Type" content="text/html; CHARSET=Big5-HKSCS">
<meta name="Comments" content="WCAG2.0_Verified" />
<meta name="Description" content="7-day Weather Forecast" />
<meta name="Keywords" content="7-day Weather Forecast" />

</HEAD>
<BODY >
<script type="text/javascript" src="/js/jquery/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="/js/clf_textonly.js"></script>
<style type="text/css">
#wcag_logo_area{
display:inline;
text-align: center;
}
#wcag_logo_area a img{
border: 0px;
position:relative;
top:12px;
}
</style>
<link rel="SHORTCUT ICON" href="/Logo.ico">
<p align="center"><img src="../../images_e/logo_dblue.gif" alt="Hong Kong Observatory Logo" width="333" height="65"> </p>
<h1 align="center">7-day Weather Forecast </h1>
<p><span style="font-style:italic;">Bulletin updated at 06:45 HKT 12/Jul/2013</span></p>
<!--7-day Weather Forecast-->
<pre>
7-Day Weather Forecast

General Situation:
As Severe Typhoon Soulik edges closer to the vicinity of
Taiwan, its outer subsiding air and the continental
airstream will bring hazy and very hot weather to Guangdong
today and tomorrow. Under the influence of a maritime
airstream, there will be showers over the coastal areas of
Guangdong early next week.

Date/Month 12/7 (Friday)
Wind: West force 2 to 3.
Weather: Fine and very hot. Isolated showers and some haze
later.
Temp Range: 27 - 34 C
R.H. Range: 60 - 90 Per Cent

Date/Month 13/7(Saturday)
Wind: West to southwest force 4.
Weather: Mainly fine and very hot with some haze. A few
showers later.
Temp Range: 28 - 33 C
R.H. Range: 60 - 90 Per Cent

Date/Month 14/7(Sunday)
Wind: South to southwest force 4.
Weather: A few showers. Sunny intervals during the day.
Temp Range: 27 - 31 C
R.H. Range: 70 - 90 Per Cent

Date/Month 15/7(Monday)
Wind: South to southeast force 3.
Weather: Hot with sunny periods. A few showers.
Temp Range: 28 - 32 C
R.H. Range: 70 - 90 Per Cent

Date/Month 16/7(Tuesday)
Wind: Southeast force 3.
Weather: A few showers. Sunny intervals during the day.
Temp Range: 27 - 31 C
R.H. Range: 75 - 95 Per Cent

Date/Month 17/7(Wednesday)
Wind: Southeast force 3.
Weather: Hot with sunny periods. A few showers.
Temp Range: 28 - 32 C
R.H. Range: 70 - 90 Per Cent

Date/Month 18/7(Thursday)
Wind: Southeast force 3.
Weather: Mainly fine and hot apart from one or two isolated
showers.
Temp Range: 28 - 32 C
R.H. Range: 65 - 90 Per Cent

Sea surface temperature at 2 p.m.11/7/2013 at North Point
was 26.5 degrees C.

Soil temperatures at 7 a.m.11/7/2013 at the Hong Kong
Observatory:
0.5 M below surface was 29.8 degrees C.
1.0 M below surface was 29.2 degrees C.

Weather Cartoons for 7-day weather forecast
Day 1 cartoon no. 90 - Hot
Day 2 cartoon no. 90 - Hot
Day 3 cartoon no. 54 - Sunny Intervals with Showers
Day 4 cartoon no. 53 - Sunny Periods with A Few Showers
Day 5 cartoon no. 54 - Sunny Intervals with Showers
Day 6 cartoon no. 53 - Sunny Periods with A Few Showers
Day 7 cartoon no. 51 - SUNNY PERIODS
</pre>
<!--/7-day Weather Forecast-->

<hr>
| <a href="../readme.htm">Copyright and Disclaimer</a> | <a href="../index.htm">Home</a> |
<a href="ndayc.htm">Chinese Version / ¤¤¤åª©¥»</a> | <a href="http://rss.weather.gov.hk/rss/SeveralDaysWeatherForecast.xml"><img src="/img/rss3.gif" alt="7-day Weather Forecast RSS" border="0"/></a> | <br/><div id="wcag_logo_area"></div>

<link rel="alternate" type="application/rss+xml" title="7-day Weather Forecast" href="http://rss.weather.gov.hk/rss/SeveralDaysWeatherForecast.xml">
</BODY>
</HTML>
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@ OTHER_FILES += \
CONFIG = link_pkgconfig -qt
PKGCONFIG += libxml-2.0

system(pkg-config --exists glib-2.0){
PKGCONFIG += glib-2.0
message(GLIB-2.0 is exist)
CONFIG += -qt
DEFINES += GLIB
}else{
message(GLIB-2.0 is not exist)
#system(pkg-config --exists glib-2.0){
# PKGCONFIG += glib-2.0
# message(GLIB-2.0 is exist)
# CONFIG += -qt
# DEFINES += GLIB
#}else{
# message(GLIB-2.0 is not exist)
CONFIG += qt
QT += core
DEFINES += QT
}
# DEFINES += QT
#}


db.files = data/hko.gov.hk.db
Expand Down
10 changes: 9 additions & 1 deletion omweather-hko-gov-hk-stations-db/src/hash.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* vim: set sw=4 ts=4 et: */
/* This file is part of Other Maemo Weather(omweather) - MeeCast
*
* Copyright (C) 2012 Vlad Vasilyeu
* Copyright (C) 2012 - 2013 Vlad Vasilyeu
* for the code
*
* Copyright (C) 2008 Andrew Zhilin
Expand Down Expand Up @@ -33,6 +33,14 @@
#undef DEBUGFUNCTIONCALL
#endif

xmlHashTablePtr
hash_icons_hko_table_create(){
xmlHashTablePtr hash;
hash = xmlHashCreate(6);
#include "hash_icons.data"
return hash;
}

#ifdef GLIB
/*******************************************************************************/
GHashTable *hash_hko_table_create(void) {
Expand Down
6 changes: 5 additions & 1 deletion omweather-hko-gov-hk-stations-db/src/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
* This file is part of Other Maemo Weather(omweather) - MeeCast
*
* Copyright (C) 2012 Vlad Vasilyeu
* Copyright (C) 2012- 2013 Vlad Vasilyeu
* for the code
*
* Copyright (C) 2008 Andrew Zhilin
Expand All @@ -28,6 +28,10 @@
#ifndef _hash_h
#define _hash_h 1
/*******************************************************************************/

#include <libxml/xpath.h>
#include <string.h>
xmlHashTablePtr hash_icons_hko_table_create();
#ifdef GLIB
GHashTable* hash_hko_table_create(void);
gpointer hash_hko_table_find(GHashTable *hash, gpointer key, gboolean search_short_name);
Expand Down
1 change: 1 addition & 0 deletions omweather-hko-gov-hk-stations-db/src/hash_icons.data
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#endif


#define hash_insert(hash, s2, s3) xmlHashAddEntry(hash, (const xmlChar *)s2, (void *)strdup(s3));
hash_insert(hash, "62", "11");
hash_insert(hash, "63", "11");
hash_insert(hash, "53", "39");
Expand Down
8 changes: 4 additions & 4 deletions omweather-hko-gov-hk-stations-db/src/meego-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
* This file is part of omweather-hko-gov-hk-stations-db - MeeCast
*
* Copyright (C) 2012 Vlad Vasilyeu
* Copyright (C) 2012 - 2013 Vlad Vasilyeu
* for the code
*
* This software is free software; you can redistribute it and/or
Expand Down Expand Up @@ -38,7 +38,7 @@
static QHash<QString, QString> *hash_for_icons;
QHash<QString, QString> *hash_hko_table_create(void);
#endif

static xmlHashTablePtr hash_for_icons;
/*******************************************************************************/
#ifdef GLIB
gchar*
Expand Down Expand Up @@ -97,7 +97,7 @@ parse_forecast_weather(const char *detail_path_data, const char *result_file){
if (strstr(buffer,"Weather Cartoons for 7-day weather forecast"))
break;
}
hash_for_icons = hash_hko_table_create();
hash_for_icons = hash_icons_hko_table_create();

while(fgets(buffer, sizeof(buffer), file_in)){
if (strstr(buffer,"Bulletin updated"))
Expand Down Expand Up @@ -231,7 +231,7 @@ parse_current_weather(const char *detail_path_data, const char *result_file){
if (!file_in)
return;

hash_for_icons = hash_hko_table_create();
hash_for_icons = hash_icons_hko_table_create();
while(fgets(buffer, sizeof(buffer), file_in)){
if (strstr(buffer,"Bulletin updated"))
if (comma = strstr(buffer, "at ")){
Expand Down
1 change: 1 addition & 0 deletions omweather-hko-gov-hk-stations-db/src/meego-main.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <stdlib.h>
#include <locale.h>
#include <sys/stat.h>
#include "hash.h"

/*******************************************************************************/
int source_init(void);
Expand Down
2 changes: 2 additions & 0 deletions omweather-hko-gov-hk-stations-db/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
./hkogovhk ./examples/nday.htm ./examples/out.xml ./examples/englishwx2.htm

0 comments on commit 4908b7e

Please sign in to comment.