[GRASS-SVN] r43701 - grass-addons/vector/v.in.gshhs
svn_grass at osgeo.org
svn_grass at osgeo.org
Mon Sep 27 08:10:46 EDT 2010
Author: neteler
Date: 2010-09-27 12:10:46 +0000 (Mon, 27 Sep 2010)
New Revision: 43701
Modified:
grass-addons/vector/v.in.gshhs/gshhs.h
grass-addons/vector/v.in.gshhs/main.c
Log:
updated to GSHHS 2.1.0
Modified: grass-addons/vector/v.in.gshhs/gshhs.h
===================================================================
--- grass-addons/vector/v.in.gshhs/gshhs.h 2010-09-27 11:47:55 UTC (rev 43700)
+++ grass-addons/vector/v.in.gshhs/gshhs.h 2010-09-27 12:10:46 UTC (rev 43701)
@@ -1,11 +1,11 @@
-/* $Id: gshhs.h,v 1.17 2008/01/23 03:22:49 guru Exp $
+/* $Id: gshhs.h,v 1.31 2010/07/18 03:16:01 guru Exp $
*
* Include file defining structures used in gshhs.c
*
* Paul Wessel, SOEST
*
- * Copyright (c) 1996-2008 by P. Wessel and W. H. F. Smith
- * See COPYING file for copying and redistribution conditions.
+ * Copyright (c) 1996-2010 by P. Wessel and W. H. F. Smith
+ * See LICENSE.TXT file for copying and redistribution conditions.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -27,9 +27,12 @@
* 28-AUG-2007. PW: Version 1.6. no format change
* For use with version 1.6 of GSHHS which now has WDBII
* borders and rivers.
- *
- * may need updating for new GSHHS versions
- *
+ * 03-JUL-2008. PW: Version 1.11. New -I<id> option to pull out a single pol
+ * 27-MAY-2009. PW: Version 1.12. Now includes container polygon ID in header,
+ * an ancestor ID, and area of the reduced polygon. Works on
+ * GSHHS 2.0 data.
+ * Header is now 44 bytes (all 4-byte integers)
+ * 24-MAY-2010. PW: Data version is now 2.1.0. [no change to format]
*/
#ifndef _GSHHS
@@ -38,8 +41,13 @@
#include <stdio.h>
#include <stdlib.h>
+#include <ctype.h>
#include <math.h>
+#ifdef WIN32
+#pragma warning( disable : 4996 )
+#endif
+
#ifndef M_PI
#define M_PI 3.14159265358979323846
#endif
@@ -48,31 +56,17 @@
#define SEEK_CUR 1
#endif
-#define GSHHS_DATA_RELEASE 7 /* For v2.0 data set */
-#define GSHHS_DATA_VERSION "2.0" /* For v2.0 data set */
+#define GSHHS_DATA_RELEASE 8 /* For v2.1.0 data set */
+#define GSHHS_DATA_VERSION "2.1.0" /* For v2.1.0 data set */
#define GSHHS_PROG_VERSION "1.12"
-#define GSHHS_SCL 1.0e-6 /* COnvert micro-degrees to degrees */
+#define GSHHS_SCL 1.0e-6 /* Convert micro-degrees to degrees */
/* For byte swapping on little-endian systems (GSHHS is defined to be bigendian) */
#define swabi4(i4) (((i4) >> 24) + (((i4) >> 8) & 65280) + (((i4) & 65280) << 8) + (((i4) & 255) << 24))
-struct GSHHS1 { /* Global Self-consistent Hierarchical High-resolution Shorelines */
- int id; /* Unique polygon id number, starting at 0 */
- int n; /* Number of points in this polygon */
- int flag; /* = level + version << 8 + greenwich << 16 + source << 24 */
- /* flag contains 4 items, one in each byte, as follows:
- * low byte: level = flag & 255: Values: 1 land, 2 lake, 3 island_in_lake, 4 pond_in_island_in_lake
- * 2nd byte: version = (flag >> 8) & 255: Values: Should be 4 for GSHHS version 1.4
- * 3rd byte: greenwich = (flag >> 16) & 255: Values: Greenwich is 1 if Greenwich is crossed
- * 4th byte: source = (flag >> 24) & 255: Values: 0 = CIA WDBII, 1 = WVS
- */
- int west, east, south, north; /* min/max extent in micro-degrees */
- int area; /* Area of polygon in 1/10 km^2 */
-};
-
-struct GSHHS2 { /* Global Self-consistent Hierarchical High-resolution Shorelines */
+struct GSHHS { /* Global Self-consistent Hierarchical High-resolution Shorelines */
int id; /* Unique polygon id number, starting at 0 */
int n; /* Number of points in this polygon */
int flag; /* = level + version << 8 + greenwich << 16 + source << 24 + river << 25 */
@@ -90,7 +84,7 @@
int ancestor; /* Id of ancestor polygon in the full resolution set that was the source of this polygon (-1 if none) */
};
-struct GSHHS_POINT { /* Each lon, lat pair is stored in micro-degrees in 4-byte integer format */
+struct GSHHS_POINT { /* Each lon, lat pair is stored in micro-degrees in 4-byte integer format */
int x;
int y;
};
Modified: grass-addons/vector/v.in.gshhs/main.c
===================================================================
--- grass-addons/vector/v.in.gshhs/main.c 2010-09-27 11:47:55 UTC (rev 43700)
+++ grass-addons/vector/v.in.gshhs/main.c 2010-09-27 12:10:46 UTC (rev 43701)
@@ -36,6 +36,7 @@
/* updating to a newer GSHHS version can be as easy as replacing
* struct GSHHS2 und updating GSHHS_DATA_RELEASE in gshhs.h
* if not too many changes were introduced */
+/* TODO 9/2010: GSHHS1 and GSHHS2 have been unified in gshhs.h, simplify code here */
#include "gshhs.h"
/* GSHHS version 1.x import */
@@ -61,7 +62,7 @@
FILE *fp;
int i, n_read, flip, version;
int cnt = 0;
- struct GSHHS1 h;
+ struct GSHHS h;
/* GRASS specific */
struct Key_Value *out_proj_keys, *out_unit_keys;
int zone;
@@ -257,7 +258,7 @@
}
/* read header from GSHHS database */
- n_read = fread((void *)&h, (size_t) sizeof(struct GSHHS1), (size_t) 1, fp);
+ n_read = fread((void *)&h, (size_t) sizeof(struct GSHHS), (size_t) 1, fp);
version = (h.flag >> 8) & 255;
/* Take as sign that byte-swapping is needed */
@@ -378,7 +379,7 @@
int max_east = 180000000; /* max_east = 270000000: confuses GRASS */
int cnt = 0, getme = 0;
struct GSHHS_POINT p; /* renamed to avoid conflict */
- struct GSHHS1 h;
+ struct GSHHS h;
/* GRASS specific */
int type;
struct line_pnts *Points, **BPoints;
@@ -386,7 +387,7 @@
int use_bpoints, n_bpoints, bpoints_alloc = 10;
/* read header from GSHHS database */
- n_read = fread((void *)&h, (size_t) sizeof(struct GSHHS1), (size_t) 1, fp);
+ n_read = fread((void *)&h, (size_t) sizeof(struct GSHHS), (size_t) 1, fp);
version = (h.flag >> 8) & 255;
/* Take as sign that byte-swapping is needed */
@@ -676,7 +677,7 @@
/* max_east = 180000000; */ /* Only Eurasiafrica needs 270 */
n_read =
- fread((void *)&h, (size_t) sizeof(struct GSHHS1), (size_t) 1, fp);
+ fread((void *)&h, (size_t) sizeof(struct GSHHS), (size_t) 1, fp);
}
Vect_destroy_line_struct(Points);
@@ -690,6 +691,7 @@
/* GSHHS version 2.x import, works with data release 7 */
/* the only difference between gshhs_import1 and gshhs_import2 is
* the use of struct GSHHS1 or struct GSHHS2, respectively */
+/* TODO 9/2010: GSHHS1 and GSHHS2 have been unified in gshhs.h, simplify code here */
int gshhs_import2(struct Map_info *Map, FILE *fp, int limit_to_region,
double minx, double maxx, double miny, double maxy)
{
@@ -700,7 +702,7 @@
int max_east = 180000000; /* max_east = 270000000: confuses GRASS */
int cnt = 0, getme = 0;
struct GSHHS_POINT p; /* renamed to avoid conflict */
- struct GSHHS2 h;
+ struct GSHHS h;
/* GRASS specific */
int type;
struct line_pnts *Points, **BPoints;
@@ -708,7 +710,7 @@
int use_bpoints, n_bpoints, bpoints_alloc = 10;
/* read header from GSHHS database */
- n_read = fread((void *)&h, (size_t) sizeof(struct GSHHS2), (size_t) 1, fp);
+ n_read = fread((void *)&h, (size_t) sizeof(struct GSHHS), (size_t) 1, fp);
version = (h.flag >> 8) & 255;
/* Take as sign that byte-swapping is needed */
@@ -998,7 +1000,7 @@
/* max_east = 180000000; */ /* Only Eurasiafrica needs 270 */
n_read =
- fread((void *)&h, (size_t) sizeof(struct GSHHS2), (size_t) 1, fp);
+ fread((void *)&h, (size_t) sizeof(struct GSHHS), (size_t) 1, fp);
}
Vect_destroy_line_struct(Points);
More information about the grass-commit
mailing list