Remove the previous static list of material identifiers and replaced them by material names. Only the clipper still has a static list for identifying priorities.
This commit is contained in:
parent
ba50776472
commit
54e72714c4
24 changed files with 355 additions and 340 deletions
|
@ -1366,8 +1366,8 @@ void build_airport( string airport_id, float alt_m,
|
|||
string holepath = root + "/AirportArea";
|
||||
// long int poly_index = poly_index_next();
|
||||
// write_boundary( holepath, b, hull, poly_index );
|
||||
tgChopNormalPolygon( holepath, HoleArea, divided_base, true );
|
||||
tgChopNormalPolygon( holepath, AirportArea, apt_clearing, false );
|
||||
tgChopNormalPolygon( holepath, "Hole", divided_base, true );
|
||||
tgChopNormalPolygon( holepath, "Airport", apt_clearing, false );
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
noinst_LIBRARIES = libClipper.a
|
||||
|
||||
libClipper_a_SOURCES = clipper.cxx clipper.hxx
|
||||
libClipper_a_SOURCES = clipper.cxx clipper.hxx priorities.cxx priorities.hxx
|
||||
|
||||
noinst_PROGRAMS = testclipper
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <simgear/debug/logstream.hxx>
|
||||
#include <simgear/misc/sgstream.hxx>
|
||||
|
||||
#include <Polygon/names.hxx>
|
||||
#include <Clipper/priorities.hxx>
|
||||
#include <Osgb36/osgb36.hxx>
|
||||
|
||||
#include "clipper.hxx"
|
||||
|
|
151
src/BuildTiles/Clipper/priorities.cxx
Normal file
151
src/BuildTiles/Clipper/priorities.cxx
Normal file
|
@ -0,0 +1,151 @@
|
|||
// priorities.cxx -- manage area type priorities
|
||||
//
|
||||
// Written by Curtis Olson, started February 1999.
|
||||
//
|
||||
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// 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
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// $Id: names.cxx,v 1.13 2004-11-19 22:25:50 curt Exp $
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
|
||||
#include <map>
|
||||
#include STL_STRING
|
||||
|
||||
#include "priorities.hxx"
|
||||
|
||||
SG_USING_STD(string);
|
||||
SG_USING_STD(map);
|
||||
|
||||
typedef map<AreaType, string> area_type_map;
|
||||
typedef map<string, AreaType> area_name_map;
|
||||
|
||||
static area_type_map area_types;
|
||||
static area_name_map area_names;
|
||||
|
||||
|
||||
inline static void set_area (const string &name, AreaType type)
|
||||
{
|
||||
area_types[type] = name;
|
||||
area_names[name] = type;
|
||||
}
|
||||
|
||||
|
||||
static bool _initialized = false;
|
||||
|
||||
|
||||
inline static void init ()
|
||||
{
|
||||
if (_initialized)
|
||||
return;
|
||||
|
||||
set_area("SomeSort", SomeSortOfArea);
|
||||
set_area("Hole", HoleArea);
|
||||
set_area("Airport", AirportArea);
|
||||
set_area("Island", IslandArea);
|
||||
set_area("Pond", PondArea);
|
||||
set_area("Swamp or Marsh", MarshArea);
|
||||
set_area("Marsh", MarshArea);
|
||||
set_area("Littoral", LittoralArea);
|
||||
set_area("Bog", BogArea);
|
||||
set_area("Sand", SandArea);
|
||||
set_area("Lava", LavaArea);
|
||||
set_area("FloodLand", FloodLandArea);
|
||||
set_area("Lake", LakeArea);
|
||||
set_area("Lake Dry", DryLakeArea);
|
||||
set_area("DryLake", DryLakeArea);
|
||||
set_area("Lake Intermittent", IntLakeArea);
|
||||
set_area("IntermittentLake", IntLakeArea);
|
||||
set_area("Reservoir", ReservoirArea);
|
||||
set_area("Reservoir Intermittent", IntReservoirArea);
|
||||
set_area("IntermittentReservoir", IntReservoirArea);
|
||||
set_area("Freeway", FreewayArea);
|
||||
set_area("Road", RoadArea);
|
||||
set_area("Railroad", RailroadArea);
|
||||
set_area("Stream", StreamArea);
|
||||
set_area("IntermittentStream", IntStreamArea);
|
||||
set_area("Canal", CanalArea);
|
||||
set_area("Glacier", GlacierArea);
|
||||
set_area("PackIce", PackIceArea);
|
||||
set_area("PolarIce", PolarIceArea);
|
||||
set_area("Urban", UrbanArea);
|
||||
set_area("Town", TownArea);
|
||||
set_area("BuiltUpCover", BuiltUpCover);
|
||||
set_area("DryCropPastureCover", DryCropPastureCover);
|
||||
set_area("IrrCropPastureCover", IrrCropPastureCover);
|
||||
set_area("MixedCropPastureCover", MixedCropPastureCover);
|
||||
set_area("CropGrassCover", CropGrassCover);
|
||||
set_area("CropWoodCover", CropWoodCover);
|
||||
set_area("GrassCover", GrassCover);
|
||||
set_area("ShrubCover", ShrubCover);
|
||||
set_area("ShrubGrassCover", ShrubGrassCover);
|
||||
set_area("SavannaCover", SavannaCover);
|
||||
set_area("DeciduousBroadCover", DeciduousBroadCover);
|
||||
set_area("DeciduousNeedleCover", DeciduousNeedleCover);
|
||||
set_area("EvergreenBroadCover", EvergreenBroadCover);
|
||||
set_area("EvergreenNeedleCover", EvergreenNeedleCover);
|
||||
set_area("MixedForestCover", MixedForestCover);
|
||||
set_area("WaterBodyCover", WaterBodyCover);
|
||||
set_area("HerbWetlandCover", HerbWetlandCover);
|
||||
set_area("WoodedWetlandCover", WoodedWetlandCover);
|
||||
set_area("BarrenCover", BarrenCover);
|
||||
set_area("HerbTundraCover", HerbTundraCover);
|
||||
set_area("WoodedTundraCover", WoodedTundraCover);
|
||||
set_area("MixedTundraCover", MixedTundraCover);
|
||||
set_area("BareTundraCover", BareTundraCover);
|
||||
set_area("SnowCover", SnowCover);
|
||||
set_area("Default", DefaultArea);
|
||||
set_area("Bay Estuary or Ocean", OceanArea);
|
||||
set_area("Ocean", OceanArea);
|
||||
set_area("Void Area", VoidArea);
|
||||
set_area("Null", NullArea);
|
||||
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
|
||||
// return area type from text name
|
||||
AreaType
|
||||
get_area_type (const string &area) {
|
||||
init();
|
||||
area_name_map::const_iterator it = area_names.find(area);
|
||||
if (it != area_names.end()) {
|
||||
return it->second;
|
||||
} else {
|
||||
SG_LOG(SG_GENERAL, SG_WARN, "unknown area = '" << area << "'");
|
||||
// SG_LOG(SG_GENERAL, SG_DEBUG, "area = " << area);
|
||||
// for ( int i = 0; i < area.length(); i++ ) {
|
||||
// SG_LOG(SG_GENERAL, SG_DEBUG, i << ") " << (int)area[i]);
|
||||
// }
|
||||
return UnknownArea;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// return text from of area name
|
||||
string get_area_name( AreaType area ) {
|
||||
init();
|
||||
area_type_map::const_iterator it = area_types.find(area);
|
||||
if (it != area_types.end()) {
|
||||
return it->second;
|
||||
} else {
|
||||
SG_LOG(SG_GENERAL, SG_WARN, "unknown area code = " << (int)area);
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
|
111
src/BuildTiles/Clipper/priorities.hxx
Normal file
111
src/BuildTiles/Clipper/priorities.hxx
Normal file
|
@ -0,0 +1,111 @@
|
|||
// priorities.hxx -- manage material priorities
|
||||
//
|
||||
// Written by Curtis Olson, started February 1999.
|
||||
//
|
||||
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// 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
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// $Id: names.hxx,v 1.14 2005-09-28 16:43:18 curt Exp $
|
||||
|
||||
|
||||
#ifndef _PRIORITIES_HXX
|
||||
#define _PRIORITIES_HXX
|
||||
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
|
||||
#include STL_STRING
|
||||
|
||||
SG_USING_STD(string);
|
||||
|
||||
|
||||
// Posible shape file types. Note the order of these is important and
|
||||
// defines the priority of these shapes if they should intersect. The
|
||||
// smaller the number, the higher the priority.
|
||||
enum AreaType {
|
||||
SomeSortOfArea = 0,
|
||||
HoleArea, // Leave area completely empty
|
||||
AirportArea,
|
||||
FreewayArea,
|
||||
RoadArea,
|
||||
RailroadArea,
|
||||
PondArea,
|
||||
LakeArea,
|
||||
DryLakeArea,
|
||||
IntLakeArea,
|
||||
ReservoirArea,
|
||||
IntReservoirArea,
|
||||
StreamArea,
|
||||
IntStreamArea,
|
||||
CanalArea,
|
||||
GlacierArea, // Solid ice/snow
|
||||
PackIceArea, // Water with ice packs
|
||||
PolarIceArea,
|
||||
OceanArea,
|
||||
UrbanArea, // Densely-populated city or large town
|
||||
TownArea, // Small town or village
|
||||
FloodLandArea, // Land subject to flooding
|
||||
BogArea, // Bog
|
||||
MarshArea, // Marshland or swamp
|
||||
SandArea, // Sand-covered area
|
||||
LittoralArea, // Tidal, Sand-covered area
|
||||
LavaArea, // Lava-covered area
|
||||
|
||||
// USGS Land Covers
|
||||
// These are low-priority, since known polygons should always win.
|
||||
|
||||
BuiltUpCover, // Urban and Built-Up Land
|
||||
DryCropPastureCover, // Dryland Cropland and Pasture
|
||||
IrrCropPastureCover, // Irrigated Cropland and Pasture
|
||||
MixedCropPastureCover, // Mixed Dryland/Irrigated Cropland and Pasture
|
||||
CropGrassCover, // Cropland/Grassland Mosaic
|
||||
CropWoodCover, // Cropland/Woodland Mosaic
|
||||
GrassCover, // Grassland
|
||||
ShrubCover, // Shrubland
|
||||
ShrubGrassCover, // Mixed Shrubland/Grassland
|
||||
SavannaCover, // Savanna
|
||||
DeciduousBroadCover, // Deciduous Broadleaf Forest
|
||||
DeciduousNeedleCover, // Deciduous Needleleaf Forest
|
||||
EvergreenBroadCover, // Evergreen Broadleaf Forest
|
||||
EvergreenNeedleCover, // Evergreen Needleleaf Forest
|
||||
MixedForestCover, // Mixed Forest
|
||||
WaterBodyCover, // Water Bodies
|
||||
HerbWetlandCover, // Herbaceous Wetland
|
||||
WoodedWetlandCover, // Wooded Wetland
|
||||
BarrenCover, // Barren or Sparsely Vegetated
|
||||
HerbTundraCover, // Herbaceous Tundra
|
||||
WoodedTundraCover, // Wooded Tundra
|
||||
MixedTundraCover, // Mixed Tundra
|
||||
BareTundraCover, // Bare Ground Tundra
|
||||
SnowCover, // Snow or Ice
|
||||
|
||||
IslandArea, // any island area not covered otherwise
|
||||
DefaultArea, // any land area not covered otherwise
|
||||
|
||||
VoidArea,
|
||||
NullArea,
|
||||
UnknownArea
|
||||
};
|
||||
|
||||
|
||||
// return area type from text name
|
||||
AreaType get_area_type( const string &area );
|
||||
|
||||
// return text form of area name
|
||||
string get_area_name( AreaType area );
|
||||
|
||||
#endif // _PRIORITIES_HXX
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
#include <simgear/misc/texcoord.hxx>
|
||||
|
||||
#include <Output/output.hxx>
|
||||
#include <Polygon/names.hxx>
|
||||
#include <Clipper/priorities.hxx>
|
||||
|
||||
#include <Osgb36/osgbtc.hxx>
|
||||
#include <Osgb36/uk.hxx>
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
|
||||
#include <Geometry/trinodes.hxx>
|
||||
#include <Geometry/trisegs.hxx>
|
||||
#include <Polygon/names.hxx>
|
||||
#include <Clipper/priorities.hxx>
|
||||
|
||||
#include <Clipper/clipper.hxx>
|
||||
#include <Triangulate/trieles.hxx>
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
#include <Geometry/trinodes.hxx>
|
||||
#include <Geometry/trisegs.hxx>
|
||||
#include <Polygon/names.hxx>
|
||||
#include <Clipper/priorities.hxx>
|
||||
#include <Polygon/polygon.hxx>
|
||||
|
||||
#define REAL double
|
||||
|
|
|
@ -3,7 +3,7 @@ noinst_LIBRARIES = libPolygon.a
|
|||
libPolygon_a_SOURCES = \
|
||||
chop-bin.cxx chop.hxx \
|
||||
index.cxx index.hxx \
|
||||
names.cxx names.hxx \
|
||||
names.hxx \
|
||||
polygon.cxx polygon.hxx \
|
||||
simple_clip.cxx simple_clip.hxx \
|
||||
superpoly.cxx superpoly.hxx
|
||||
|
|
|
@ -42,12 +42,12 @@
|
|||
#include <Output/output.hxx>
|
||||
|
||||
#include "index.hxx"
|
||||
#include "names.hxx"
|
||||
#include "simple_clip.hxx"
|
||||
#include "chop.hxx"
|
||||
|
||||
|
||||
static void clip_and_write_poly( string root, long int p_index, AreaType area,
|
||||
static void clip_and_write_poly( string root, long int p_index,
|
||||
const string &poly_type,
|
||||
SGBucket b, const TGPolygon& shape,
|
||||
bool preserve3d ) {
|
||||
Point3D c, min, max, p;
|
||||
|
@ -137,9 +137,6 @@ static void clip_and_write_poly( string root, long int p_index, AreaType area,
|
|||
polyfile += ".";
|
||||
polyfile += poly_index;
|
||||
|
||||
string poly_type = get_area_name( area );
|
||||
if ( poly_type == "Unknown" )
|
||||
throw sg_exception("unknown area type in clip_and_write_poly()!");
|
||||
|
||||
FILE *rfp= fopen( polyfile.c_str(), "w" );
|
||||
if ( preserve3d ) {
|
||||
|
@ -166,10 +163,9 @@ static void clip_and_write_poly( string root, long int p_index, AreaType area,
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// process polygon shape (chop up along tile boundaries and write each
|
||||
// polygon piece to a file)
|
||||
void tgChopNormalPolygon( const string& path, AreaType area,
|
||||
void tgChopNormalPolygon( const string& path, const string& poly_type,
|
||||
const TGPolygon& shape, bool preserve3d )
|
||||
{
|
||||
Point3D min, max, p;
|
||||
|
@ -212,7 +208,7 @@ void tgChopNormalPolygon( const string& path, AreaType area,
|
|||
|
||||
if ( b_min == b_max ) {
|
||||
// shape entirely contained in a single bucket, write and bail
|
||||
clip_and_write_poly( path, index, area, b_min, shape, preserve3d );
|
||||
clip_and_write_poly( path, index, poly_type, b_min, shape, preserve3d );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -233,7 +229,7 @@ void tgChopNormalPolygon( const string& path, AreaType area,
|
|||
for ( j = 0; j <= dy; ++j ) {
|
||||
for ( i = 0; i <= dx; ++i ) {
|
||||
b_cur = sgBucketOffset(min.x(), min.y(), i, j);
|
||||
clip_and_write_poly( path, index, area, b_cur, shape,
|
||||
clip_and_write_poly( path, index, poly_type, b_cur, shape,
|
||||
preserve3d );
|
||||
}
|
||||
}
|
||||
|
@ -286,7 +282,7 @@ void tgChopNormalPolygon( const string& path, AreaType area,
|
|||
|
||||
bottom_clip = tgPolygonInt( bottom, shape );
|
||||
|
||||
tgChopNormalPolygon( path, area, bottom_clip, preserve3d );
|
||||
tgChopNormalPolygon( path, poly_type, bottom_clip, preserve3d );
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -312,16 +308,15 @@ void tgChopNormalPolygon( const string& path, AreaType area,
|
|||
|
||||
top_clip = tgPolygonInt( top, shape );
|
||||
|
||||
tgChopNormalPolygon( path, area, top_clip, preserve3d );
|
||||
tgChopNormalPolygon( path, poly_type, top_clip, preserve3d );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// process polygon shape (chop up along tile boundaries and write each
|
||||
// polygon piece to a file) This has a front end to a crude clipper
|
||||
// that doesn't handle holes so beware. This routine is appropriate
|
||||
// for breaking down really huge structures if needed.
|
||||
void tgChopBigSimplePolygon( const string& path, AreaType area,
|
||||
void tgChopBigSimplePolygon( const string& path, const string& poly_type,
|
||||
const TGPolygon& shape, bool preserve3d )
|
||||
{
|
||||
Point3D min, max, p;
|
||||
|
@ -364,7 +359,7 @@ void tgChopBigSimplePolygon( const string& path, AreaType area,
|
|||
|
||||
if ( b_min == b_max ) {
|
||||
// shape entirely contained in a single bucket, write and bail
|
||||
clip_and_write_poly( path, index, area, b_min, shape, preserve3d );
|
||||
clip_and_write_poly( path, index, poly_type, b_min, shape, preserve3d );
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -386,7 +381,7 @@ void tgChopBigSimplePolygon( const string& path, AreaType area,
|
|||
for ( j = 0; j <= 1; ++j ) {
|
||||
for ( i = 0; i <= dx; ++i ) {
|
||||
b_cur = sgBucketOffset(min.x(), min.y(), i, j);
|
||||
clip_and_write_poly( path, index, area, b_cur, shape,
|
||||
clip_and_write_poly( path, index, poly_type, b_cur, shape,
|
||||
preserve3d );
|
||||
}
|
||||
}
|
||||
|
@ -440,7 +435,7 @@ void tgChopBigSimplePolygon( const string& path, AreaType area,
|
|||
bottom_clip = horizontal_clip( shape, clip_line, Below );
|
||||
}
|
||||
|
||||
tgChopBigSimplePolygon( path, area, bottom_clip, preserve3d );
|
||||
tgChopBigSimplePolygon( path, poly_type, bottom_clip, preserve3d );
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -469,6 +464,6 @@ void tgChopBigSimplePolygon( const string& path, AreaType area,
|
|||
top_clip = horizontal_clip( shape, clip_line, Above );
|
||||
}
|
||||
|
||||
tgChopBigSimplePolygon( path, area, top_clip, preserve3d );
|
||||
tgChopBigSimplePolygon( path, poly_type, top_clip, preserve3d );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,13 +27,12 @@
|
|||
#define _TG_CHOP_HXX
|
||||
|
||||
|
||||
#include "names.hxx"
|
||||
#include "polygon.hxx"
|
||||
|
||||
|
||||
// process polygon shape (chop up along tile boundaries and write each
|
||||
// polygon piece to a file)
|
||||
void tgChopNormalPolygon( const string& path, AreaType area,
|
||||
void tgChopNormalPolygon( const string& path, const string& poly_type,
|
||||
const TGPolygon& shape, bool preserve3d );
|
||||
|
||||
|
||||
|
@ -41,10 +40,9 @@ void tgChopNormalPolygon( const string& path, AreaType area,
|
|||
// polygon piece to a file) This has a front end to a crude clipper
|
||||
// that doesn't handle holes so beware. This routine is appropriate
|
||||
// for breaking down really huge structures if needed.
|
||||
void tgChopBigSimplePolygon( const string& path, AreaType area,
|
||||
void tgChopBigSimplePolygon( const string& path, const string& poly_type,
|
||||
const TGPolygon& shape, bool preserve3d );
|
||||
|
||||
|
||||
#endif // _TG_CHOP_HXX
|
||||
|
||||
|
||||
|
|
|
@ -1,153 +1 @@
|
|||
// names.cxx -- process shapefiles names
|
||||
//
|
||||
// Written by Curtis Olson, started February 1999.
|
||||
//
|
||||
// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
|
||||
//
|
||||
// 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
|
||||
// the Free Software Foundation; either version 2 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program; if not, write to the Free Software
|
||||
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
//
|
||||
// $Id: names.cxx,v 1.15 2007-10-31 15:05:13 curt Exp $
|
||||
|
||||
#include <simgear/compiler.h>
|
||||
#include <simgear/debug/logstream.hxx>
|
||||
|
||||
#include <map>
|
||||
#include STL_STRING
|
||||
|
||||
#include "names.hxx"
|
||||
|
||||
SG_USING_STD(string);
|
||||
SG_USING_STD(map);
|
||||
|
||||
typedef map<AreaType, string> area_type_map;
|
||||
typedef map<string, AreaType> area_name_map;
|
||||
|
||||
static area_type_map area_types;
|
||||
static area_name_map area_names;
|
||||
|
||||
|
||||
inline static void set_area (const string &name, AreaType type)
|
||||
{
|
||||
area_types[type] = name;
|
||||
area_names[name] = type;
|
||||
}
|
||||
|
||||
|
||||
static bool _initialized = false;
|
||||
|
||||
|
||||
inline static void init ()
|
||||
{
|
||||
if (_initialized)
|
||||
return;
|
||||
|
||||
set_area("SomeSort", SomeSortOfArea);
|
||||
set_area("Hole", HoleArea);
|
||||
set_area("Airport", AirportArea);
|
||||
set_area("Island", IslandArea);
|
||||
set_area("Pond", PondArea);
|
||||
set_area("Swamp or Marsh", MarshArea);
|
||||
set_area("Marsh", MarshArea);
|
||||
set_area("Littoral", LittoralArea);
|
||||
set_area("Bog", BogArea);
|
||||
set_area("Sand", SandArea);
|
||||
set_area("Lava", LavaArea);
|
||||
set_area("FloodLand", FloodLandArea);
|
||||
set_area("Lake", LakeArea);
|
||||
set_area("Lake Dry", DryLakeArea);
|
||||
set_area("DryLake", DryLakeArea);
|
||||
set_area("Lake Intermittent", IntLakeArea);
|
||||
set_area("IntermittentLake", IntLakeArea);
|
||||
set_area("Reservoir", ReservoirArea);
|
||||
set_area("Reservoir Intermittent", IntReservoirArea);
|
||||
set_area("IntermittentReservoir", IntReservoirArea);
|
||||
set_area("YellowLine", YellowLineArea);
|
||||
set_area("WhiteLine", WhiteLineArea);
|
||||
set_area("Freeway", FreewayArea);
|
||||
set_area("Road", RoadArea);
|
||||
set_area("Railroad", RailroadArea);
|
||||
set_area("Stream", StreamArea);
|
||||
set_area("IntermittentStream", IntStreamArea);
|
||||
set_area("Canal", CanalArea);
|
||||
set_area("Glacier", GlacierArea);
|
||||
set_area("PackIce", PackIceArea);
|
||||
set_area("PolarIce", PolarIceArea);
|
||||
set_area("Urban", UrbanArea);
|
||||
set_area("Town", TownArea);
|
||||
set_area("BuiltUpCover", BuiltUpCover);
|
||||
set_area("DryCropPastureCover", DryCropPastureCover);
|
||||
set_area("IrrCropPastureCover", IrrCropPastureCover);
|
||||
set_area("MixedCropPastureCover", MixedCropPastureCover);
|
||||
set_area("CropGrassCover", CropGrassCover);
|
||||
set_area("CropWoodCover", CropWoodCover);
|
||||
set_area("GrassCover", GrassCover);
|
||||
set_area("ShrubCover", ShrubCover);
|
||||
set_area("ShrubGrassCover", ShrubGrassCover);
|
||||
set_area("SavannaCover", SavannaCover);
|
||||
set_area("DeciduousBroadCover", DeciduousBroadCover);
|
||||
set_area("DeciduousNeedleCover", DeciduousNeedleCover);
|
||||
set_area("EvergreenBroadCover", EvergreenBroadCover);
|
||||
set_area("EvergreenNeedleCover", EvergreenNeedleCover);
|
||||
set_area("MixedForestCover", MixedForestCover);
|
||||
set_area("WaterBodyCover", WaterBodyCover);
|
||||
set_area("HerbWetlandCover", HerbWetlandCover);
|
||||
set_area("WoodedWetlandCover", WoodedWetlandCover);
|
||||
set_area("BarrenCover", BarrenCover);
|
||||
set_area("HerbTundraCover", HerbTundraCover);
|
||||
set_area("WoodedTundraCover", WoodedTundraCover);
|
||||
set_area("MixedTundraCover", MixedTundraCover);
|
||||
set_area("BareTundraCover", BareTundraCover);
|
||||
set_area("SnowCover", SnowCover);
|
||||
set_area("Default", DefaultArea);
|
||||
set_area("Bay Estuary or Ocean", OceanArea);
|
||||
set_area("Ocean", OceanArea);
|
||||
set_area("Void Area", VoidArea);
|
||||
set_area("Null", NullArea);
|
||||
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
|
||||
// return area type from text name
|
||||
AreaType
|
||||
get_area_type (const string &area) {
|
||||
init();
|
||||
area_name_map::const_iterator it = area_names.find(area);
|
||||
if (it != area_names.end()) {
|
||||
return it->second;
|
||||
} else {
|
||||
SG_LOG(SG_GENERAL, SG_WARN, "unknown area = '" << area << "'");
|
||||
// SG_LOG(SG_GENERAL, SG_DEBUG, "area = " << area);
|
||||
// for ( int i = 0; i < area.length(); i++ ) {
|
||||
// SG_LOG(SG_GENERAL, SG_DEBUG, i << ") " << (int)area[i]);
|
||||
// }
|
||||
return UnknownArea;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// return text from of area name
|
||||
string get_area_name( AreaType area ) {
|
||||
init();
|
||||
area_type_map::const_iterator it = area_types.find(area);
|
||||
if (it != area_types.end()) {
|
||||
return it->second;
|
||||
} else {
|
||||
SG_LOG(SG_GENERAL, SG_WARN, "unknown area code = " << (int)area);
|
||||
return "Unknown";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -31,84 +31,20 @@
|
|||
|
||||
SG_USING_STD(string);
|
||||
|
||||
inline static bool is_ocean_area( const string &area )
|
||||
{
|
||||
return area=="Ocean" || area=="Bay Estuary or Ocean";
|
||||
}
|
||||
|
||||
// Posible shape file types. Note the order of these is important and
|
||||
// defines the priority of these shapes if they should intersect. The
|
||||
// smaller the number, the higher the priority.
|
||||
enum AreaType {
|
||||
SomeSortOfArea = 0,
|
||||
HoleArea, // Leave area completely empty
|
||||
AirportArea,
|
||||
YellowLineArea,
|
||||
WhiteLineArea,
|
||||
FreewayArea,
|
||||
RoadArea,
|
||||
RailroadArea,
|
||||
PondArea,
|
||||
LakeArea,
|
||||
DryLakeArea,
|
||||
IntLakeArea,
|
||||
ReservoirArea,
|
||||
IntReservoirArea,
|
||||
StreamArea,
|
||||
IntStreamArea,
|
||||
CanalArea,
|
||||
GlacierArea, // Solid ice/snow
|
||||
PackIceArea, // Water with ice packs
|
||||
PolarIceArea,
|
||||
OceanArea,
|
||||
UrbanArea, // Densely-populated city or large town
|
||||
TownArea, // Small town or village
|
||||
FloodLandArea, // Land subject to flooding
|
||||
BogArea, // Bog
|
||||
MarshArea, // Marshland or swamp
|
||||
SandArea, // Sand-covered area
|
||||
LittoralArea, // Tidal, Sand-covered area
|
||||
LavaArea, // Lava-covered area
|
||||
|
||||
// USGS Land Covers
|
||||
// These are low-priority, since known polygons should always win.
|
||||
|
||||
BuiltUpCover, // Urban and Built-Up Land
|
||||
DryCropPastureCover, // Dryland Cropland and Pasture
|
||||
IrrCropPastureCover, // Irrigated Cropland and Pasture
|
||||
MixedCropPastureCover, // Mixed Dryland/Irrigated Cropland and Pasture
|
||||
CropGrassCover, // Cropland/Grassland Mosaic
|
||||
CropWoodCover, // Cropland/Woodland Mosaic
|
||||
GrassCover, // Grassland
|
||||
ShrubCover, // Shrubland
|
||||
ShrubGrassCover, // Mixed Shrubland/Grassland
|
||||
SavannaCover, // Savanna
|
||||
DeciduousBroadCover, // Deciduous Broadleaf Forest
|
||||
DeciduousNeedleCover, // Deciduous Needleleaf Forest
|
||||
EvergreenBroadCover, // Evergreen Broadleaf Forest
|
||||
EvergreenNeedleCover, // Evergreen Needleleaf Forest
|
||||
MixedForestCover, // Mixed Forest
|
||||
WaterBodyCover, // Water Bodies
|
||||
HerbWetlandCover, // Herbaceous Wetland
|
||||
WoodedWetlandCover, // Wooded Wetland
|
||||
BarrenCover, // Barren or Sparsely Vegetated
|
||||
HerbTundraCover, // Herbaceous Tundra
|
||||
WoodedTundraCover, // Wooded Tundra
|
||||
MixedTundraCover, // Mixed Tundra
|
||||
BareTundraCover, // Bare Ground Tundra
|
||||
SnowCover, // Snow or Ice
|
||||
|
||||
IslandArea, // any island area not covered otherwise
|
||||
DefaultArea, // any land area not covered otherwise
|
||||
|
||||
VoidArea,
|
||||
NullArea,
|
||||
UnknownArea
|
||||
};
|
||||
|
||||
|
||||
// return area type from text name
|
||||
AreaType get_area_type( const string &area );
|
||||
|
||||
// return text form of area name
|
||||
string get_area_name( AreaType area );
|
||||
inline static bool is_void_area( const string &area )
|
||||
{
|
||||
return area=="Void Area";
|
||||
}
|
||||
|
||||
inline static bool is_null_area( const string& area )
|
||||
{
|
||||
return area=="Null";
|
||||
}
|
||||
|
||||
#endif // _NAMES_HXX
|
||||
|
||||
|
|
|
@ -46,7 +46,6 @@ SG_USING_STD(vector);
|
|||
#include <Geometry/util.hxx>
|
||||
#include <Polygon/chop.hxx>
|
||||
#include <Polygon/index.hxx>
|
||||
#include <Polygon/names.hxx>
|
||||
#include <Polygon/polygon.hxx>
|
||||
#include <e00/e00.hxx>
|
||||
|
||||
|
@ -162,7 +161,7 @@ checkAttribute (const E00 &data, int index, const Attribute &att)
|
|||
*/
|
||||
static void
|
||||
processPoints (const E00 &data, const tg::Rectangle &bounds,
|
||||
AreaType areaType, const string &workDir, int width)
|
||||
const string& poly_type, const string &workDir, int width)
|
||||
{
|
||||
// double x, y, az;
|
||||
|
||||
|
@ -179,7 +178,7 @@ processPoints (const E00 &data, const tg::Rectangle &bounds,
|
|||
}
|
||||
|
||||
tg::makePolygon(p, width, shape);
|
||||
tgChopNormalPolygon(workDir, areaType, shape, false);
|
||||
tgChopNormalPolygon(workDir, poly_type, shape, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -195,7 +194,7 @@ processPoints (const E00 &data, const tg::Rectangle &bounds,
|
|||
*/
|
||||
static void
|
||||
processLines (const E00 &data, const tg::Rectangle &bounds,
|
||||
AreaType areaType, const string &workDir, int width,
|
||||
const string& poly_type, const string &workDir, int width,
|
||||
const vector<Attribute> &aat_list)
|
||||
{
|
||||
int nLines = data.nLines();
|
||||
|
@ -242,7 +241,7 @@ processLines (const E00 &data, const tg::Rectangle &bounds,
|
|||
cout << " Minimum angle: "
|
||||
<< (shape.minangle_contour(0) * SGD_RADIANS_TO_DEGREES) << endl;
|
||||
|
||||
tgChopNormalPolygon(workDir, areaType, shape, false);
|
||||
tgChopNormalPolygon(workDir, poly_type, shape, false);
|
||||
}
|
||||
cout << "Done lines" << endl;
|
||||
}
|
||||
|
@ -253,7 +252,7 @@ processLines (const E00 &data, const tg::Rectangle &bounds,
|
|||
*/
|
||||
static void
|
||||
processPolygons (const E00 &data, const tg::Rectangle &bounds,
|
||||
AreaType areaType, const string &workDir,
|
||||
const string& poly_type, const string &workDir,
|
||||
const vector<Attribute> pat_list)
|
||||
{
|
||||
int nPolygons = data.nPolygons();
|
||||
|
@ -309,7 +308,7 @@ processPolygons (const E00 &data, const tg::Rectangle &bounds,
|
|||
0.0));
|
||||
}
|
||||
}
|
||||
tgChopNormalPolygon(workDir, areaType, shape, false);
|
||||
tgChopNormalPolygon(workDir, poly_type, shape, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -381,7 +380,7 @@ main (int argc, const char **argv)
|
|||
// Default values
|
||||
tg::Rectangle bounds(Point3D(-180.0, -90.0, 0),
|
||||
Point3D(180.0, 90.0, 0));
|
||||
AreaType areaType = DefaultArea;
|
||||
string poly_type = "Default";
|
||||
int pointWidth = 500;
|
||||
int lineWidth = 50;
|
||||
string workDir = ".";
|
||||
|
@ -453,7 +452,7 @@ main (int argc, const char **argv)
|
|||
}
|
||||
|
||||
else if (arg.find("--area=") == 0) {
|
||||
areaType = get_area_type(arg.substr(7).c_str());
|
||||
poly_type = arg.substr(7);
|
||||
argPos++;
|
||||
}
|
||||
|
||||
|
@ -514,7 +513,7 @@ main (int argc, const char **argv)
|
|||
cout << "Bounds are " << bounds.getMin().x() << ','
|
||||
<< bounds.getMin().y() << " and "
|
||||
<< bounds.getMax().x() << ',' << bounds.getMax().y() << endl;
|
||||
cout << "Area type is " << get_area_name(areaType) << endl;;
|
||||
cout << "Area type is " << poly_type << endl;;
|
||||
cout << "Working directory is " << workDir << endl;
|
||||
if (usePoints)
|
||||
cout << "Using points with width " << pointWidth << " meters" << endl;
|
||||
|
@ -581,13 +580,13 @@ main (int argc, const char **argv)
|
|||
poly_index_init( counter_file );
|
||||
|
||||
if (usePoints)
|
||||
processPoints(data, bounds, areaType, workDir, pointWidth);
|
||||
processPoints(data, bounds, poly_type, workDir, pointWidth);
|
||||
|
||||
if (useLines)
|
||||
processLines(data, bounds, areaType, workDir, lineWidth, aat_list);
|
||||
processLines(data, bounds, poly_type, workDir, lineWidth, aat_list);
|
||||
|
||||
if (usePolygons)
|
||||
processPolygons(data, bounds, areaType, workDir, pat_list);
|
||||
processPolygons(data, bounds, poly_type, workDir, pat_list);
|
||||
|
||||
cout << "Done processing " << argv[argPos] << endl;
|
||||
argPos++;
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
#include <simgear/debug/logstream.hxx>
|
||||
|
||||
#include <Polygon/index.hxx>
|
||||
#include <Polygon/names.hxx>
|
||||
#include <Polygon/polygon.hxx>
|
||||
|
||||
#include "gshhs.h"
|
||||
|
@ -50,14 +49,6 @@
|
|||
SG_USING_STD(cout);
|
||||
SG_USING_STD(cin);
|
||||
|
||||
// return the type of the shapefile record
|
||||
AreaType get_shapefile_type(int rec) {
|
||||
string area;
|
||||
|
||||
return get_area_type( area );
|
||||
}
|
||||
|
||||
|
||||
// write result to unique file name
|
||||
void write_result( const TGPolygon& result ) {
|
||||
static int count = 0;
|
||||
|
|
|
@ -33,7 +33,6 @@
|
|||
|
||||
#include <Polygon/chop.hxx>
|
||||
#include <Polygon/index.hxx>
|
||||
#include <Polygon/names.hxx>
|
||||
#include <Polygon/polygon.hxx>
|
||||
#include <Polygon/simple_clip.hxx>
|
||||
|
||||
|
@ -46,7 +45,7 @@ SG_USING_STD(string);
|
|||
// process shape front end ... split shape into lon = -180 ... 180,
|
||||
// -360 ... -180, and 180 ... 360 ... shift the offset sections and
|
||||
// process each separately
|
||||
void split_and_shift_chunk( const string& path, AreaType area,
|
||||
void split_and_shift_chunk( const string& path, const string& poly_type,
|
||||
const TGPolygon& shape )
|
||||
{
|
||||
TGPolygon lower_mask, center_mask, upper_mask;
|
||||
|
@ -86,19 +85,19 @@ void split_and_shift_chunk( const string& path, AreaType area,
|
|||
upper_shape.shift( -360, 0 );
|
||||
|
||||
SG_LOG ( SG_GENERAL, SG_INFO, "Processing lower shape" );
|
||||
tgChopBigSimplePolygon(path, area, lower_shape, false);
|
||||
tgChopBigSimplePolygon(path, poly_type, lower_shape, false);
|
||||
|
||||
SG_LOG ( SG_GENERAL, SG_INFO, "Processing center shape" );
|
||||
tgChopBigSimplePolygon(path, area, center_shape, false);
|
||||
tgChopBigSimplePolygon(path, poly_type, center_shape, false);
|
||||
|
||||
SG_LOG ( SG_GENERAL, SG_INFO, "Processing upper shape" );
|
||||
tgChopBigSimplePolygon(path, area, upper_shape, false);
|
||||
tgChopBigSimplePolygon(path, poly_type, upper_shape, false);
|
||||
}
|
||||
|
||||
|
||||
// process a large shape through my crude polygon splitter to reduce
|
||||
// the polygon sizes before handing off to gpc
|
||||
void gshhs_split_polygon( const string& path, AreaType area, TGPolygon& shape,
|
||||
void gshhs_split_polygon( const string& path, const string& poly_type, TGPolygon& shape,
|
||||
const double min, const double max )
|
||||
{
|
||||
double base_line = (int)(min - 1.0);
|
||||
|
@ -142,7 +141,7 @@ void gshhs_split_polygon( const string& path, AreaType area, TGPolygon& shape,
|
|||
// cout << "exiting early" << endl;
|
||||
// exit(0);
|
||||
|
||||
split_and_shift_chunk(path, area, below);
|
||||
split_and_shift_chunk(path, poly_type, below);
|
||||
|
||||
shape = above;
|
||||
|
||||
|
|
|
@ -25,20 +25,19 @@
|
|||
#define _GSHHS_SPLIT_HXX
|
||||
|
||||
|
||||
#include <Polygon/names.hxx>
|
||||
#include <Polygon/polygon.hxx>
|
||||
|
||||
|
||||
// process shape front end ... split shape into lon = -180 ... 180,
|
||||
// -360 ... -180, and 180 ... 360 ... shift the offset sections and
|
||||
// process each separately
|
||||
void split_and_shift_chunk( const string& path, AreaType area,
|
||||
void split_and_shift_chunk( const string& path, const string& poly_type,
|
||||
const TGPolygon& shape );
|
||||
|
||||
|
||||
// process a large shape through my crude polygon splitter to reduce
|
||||
// the polygon sizes before handing off to gpc
|
||||
void gshhs_split_polygon( const string& path, AreaType area, TGPolygon& shape,
|
||||
void gshhs_split_polygon( const string& path, const string& poly_type, TGPolygon& shape,
|
||||
const double min, const double max );
|
||||
|
||||
|
||||
|
|
|
@ -36,7 +36,6 @@
|
|||
#include <simgear/debug/logstream.hxx>
|
||||
|
||||
#include <Polygon/index.hxx>
|
||||
#include <Polygon/names.hxx>
|
||||
#include <Polygon/polygon.hxx>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
@ -209,18 +208,16 @@ int main( int argc, char **argv ) {
|
|||
// huge polygons into something more managable
|
||||
|
||||
if ( force_area_type.length() > 0 ) {
|
||||
AreaType area = get_area_type( force_area_type );
|
||||
gshhs_split_polygon(path, area, shape, s, n);
|
||||
gshhs_split_polygon(path, force_area_type, shape, s, n);
|
||||
} else {
|
||||
gshhs_split_polygon(path, DefaultArea, shape, s, n);
|
||||
gshhs_split_polygon(path, "Default", shape, s, n);
|
||||
}
|
||||
} else {
|
||||
// small enough to feed to gpc directly
|
||||
if ( force_area_type.length() > 0 ) {
|
||||
AreaType area = get_area_type( force_area_type );
|
||||
split_and_shift_chunk(path, area, shape);
|
||||
split_and_shift_chunk(path, force_area_type, shape);
|
||||
} else {
|
||||
split_and_shift_chunk(path, DefaultArea, shape);
|
||||
split_and_shift_chunk(path, "Default", shape);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,6 @@ SUBDIRS = \
|
|||
DemRaw2ascii \
|
||||
E00Lines \
|
||||
GSHHS \
|
||||
MergerClipper \
|
||||
Photo \
|
||||
ShapeFile \
|
||||
TGVPF \
|
||||
|
|
|
@ -329,7 +329,7 @@ int main( int argc, char **argv ) {
|
|||
poly_index_init( counter_file );
|
||||
|
||||
string holepath = root + "/PhotoArea";
|
||||
tgChopNormalPolygon( holepath, HoleArea, hole, false );
|
||||
tgChopNormalPolygon( holepath, "Hole", hole, false );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -31,7 +31,6 @@
|
|||
|
||||
#include <Polygon/chop.hxx>
|
||||
#include <Polygon/index.hxx>
|
||||
#include <Polygon/names.hxx>
|
||||
#include <Polygon/polygon.hxx>
|
||||
#include <shapelib/shapefil.h>
|
||||
|
||||
|
@ -43,7 +42,7 @@ SG_USING_STD( cout );
|
|||
SG_USING_STD( string );
|
||||
|
||||
// return the type of the shapefile record
|
||||
AreaType get_shapefile_type(DBFHandle& hDBF, int rec) {
|
||||
std::string get_shapefile_type(DBFHandle& hDBF, int rec) {
|
||||
|
||||
#if 0
|
||||
int *panWidth, i, iRecord;
|
||||
|
@ -249,7 +248,7 @@ AreaType get_shapefile_type(DBFHandle& hDBF, int rec) {
|
|||
area = "Null";
|
||||
}
|
||||
|
||||
return get_area_type( area );
|
||||
return area;
|
||||
}
|
||||
|
||||
|
||||
|
@ -335,13 +334,12 @@ int main( int argc, char **argv ) {
|
|||
<< " rings = " << psShape->nParts
|
||||
<< " total vertices = " << psShape->nVertices );
|
||||
|
||||
AreaType area = DefaultArea;
|
||||
string area = "Default";
|
||||
if ( force_area_type.length() == 0 ) {
|
||||
area = get_shapefile_type(hDBF, i);
|
||||
SG_LOG( SG_GENERAL, SG_DEBUG, " area type = "
|
||||
<< get_area_name(area) << " (" << (int)area << ")" );
|
||||
SG_LOG( SG_GENERAL, SG_DEBUG, " area type = " << area);
|
||||
} else {
|
||||
area = get_area_type( force_area_type );
|
||||
area = force_area_type;
|
||||
}
|
||||
|
||||
SG_LOG( SG_GENERAL, SG_INFO, " record type = "
|
||||
|
@ -416,9 +414,9 @@ int main( int argc, char **argv ) {
|
|||
// interior of polygon is assigned to force_area_type,
|
||||
// holes are preserved
|
||||
|
||||
area = get_area_type( force_area_type );
|
||||
area = force_area_type;
|
||||
tgChopNormalPolygon(work_dir, area, shape, false);
|
||||
} else if ( area == OceanArea ) {
|
||||
} else if ( is_ocean_area(area) ) {
|
||||
// interior of polygon is ocean, holes are islands
|
||||
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, "Ocean area ... SKIPPING!" );
|
||||
|
@ -426,7 +424,7 @@ int main( int argc, char **argv ) {
|
|||
// Ocean data now comes from GSHHS so we want to ignore
|
||||
// all other ocean data
|
||||
// tgChopPolygon(work_dir, area, shape, false);
|
||||
} else if ( area == VoidArea ) {
|
||||
} else if ( is_void_area(area) ) {
|
||||
// interior is ????
|
||||
|
||||
// skip for now
|
||||
|
@ -438,7 +436,7 @@ int main( int argc, char **argv ) {
|
|||
}
|
||||
|
||||
// tgChopPolygon(work_dir, area, shape, false);
|
||||
} else if ( area == NullArea ) {
|
||||
} else if ( is_null_area(area) ) {
|
||||
// interior is ????
|
||||
|
||||
// skip for now
|
||||
|
|
|
@ -40,8 +40,8 @@
|
|||
#include <Geometry/util.hxx>
|
||||
#include <Polygon/chop.hxx>
|
||||
#include <Polygon/index.hxx>
|
||||
#include <Polygon/names.hxx>
|
||||
#include <Polygon/polygon.hxx>
|
||||
#include <Polygon/names.hxx>
|
||||
#include <shapelib/shapefil.h>
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
@ -118,7 +118,7 @@ void load_noaa_area_codes() {
|
|||
}
|
||||
|
||||
// return the type of the shapefile record
|
||||
AreaType get_shapefile_type(DBFHandle& hDBF, int rec) {
|
||||
string get_shapefile_type(DBFHandle& hDBF, int rec) {
|
||||
#if 0
|
||||
int *panWidth, i, iRecord;
|
||||
char szFormat[32];
|
||||
|
@ -238,7 +238,7 @@ AreaType get_shapefile_type(DBFHandle& hDBF, int rec) {
|
|||
}
|
||||
}
|
||||
|
||||
return get_area_type( area );
|
||||
return area;
|
||||
}
|
||||
|
||||
// get attribute value of 'width' from shapefile
|
||||
|
@ -272,7 +272,7 @@ string get_attribute(DBFHandle& hDBF, int rec, int column) {
|
|||
|
||||
void processPolygon(SHPObject* psShape,
|
||||
const string& work_dir,
|
||||
AreaType area,
|
||||
const string& poly_type,
|
||||
bool preserve3D) {
|
||||
int iPart,j;
|
||||
TGPolygon shape;
|
||||
|
@ -330,7 +330,7 @@ void processPolygon(SHPObject* psShape,
|
|||
if ( max_segment > 1.0 ) {
|
||||
shape = tgPolygonSplitLongEdges( shape, max_segment );
|
||||
}
|
||||
tgChopNormalPolygon(work_dir, area, shape, preserve3D);
|
||||
tgChopNormalPolygon(work_dir, poly_type, shape, preserve3D);
|
||||
}
|
||||
|
||||
|
||||
|
@ -484,7 +484,7 @@ tg::Line fixDegenerateLine3( tg::Line line ) {
|
|||
|
||||
void processLine(SHPObject* psShape,
|
||||
const string& work_dir,
|
||||
AreaType area,
|
||||
const string& poly_type,
|
||||
float linewidth) {
|
||||
int iPart,j=0,partEnd=psShape->nVertices;
|
||||
double minx = 200, miny = 200, maxx = -200, maxy = -200;
|
||||
|
@ -538,13 +538,13 @@ void processLine(SHPObject* psShape,
|
|||
shape = tgPolygonSplitLongEdges( shape, max_segment );
|
||||
}
|
||||
cout << "hole flag = " << shape.get_hole_flag(0) << endl;
|
||||
tgChopNormalPolygon(work_dir, area, shape, false);
|
||||
tgChopNormalPolygon(work_dir, poly_type, shape, false);
|
||||
}
|
||||
}
|
||||
|
||||
void processPoints(SHPObject* psShape,
|
||||
const string& work_dir,
|
||||
AreaType area,
|
||||
const string& poly_type,
|
||||
int pointwidth) {
|
||||
TGPolygon shape;
|
||||
int j;
|
||||
|
@ -564,7 +564,7 @@ void processPoints(SHPObject* psShape,
|
|||
if ( max_segment > 1.0 ) {
|
||||
shape = tgPolygonSplitLongEdges( shape, max_segment );
|
||||
}
|
||||
tgChopNormalPolygon(work_dir, area, shape, false);
|
||||
tgChopNormalPolygon(work_dir, poly_type, shape, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -815,13 +815,12 @@ int main( int argc, char **argv ) {
|
|||
exit(-1);
|
||||
}
|
||||
|
||||
AreaType area = DefaultArea;
|
||||
string area = "Default";
|
||||
if ( force_area_type.length() == 0 ) {
|
||||
area = get_shapefile_type(hDBF, i);
|
||||
SG_LOG( SG_GENERAL, SG_DEBUG, " area type = "
|
||||
<< get_area_name(area) << " (" << (int)area << ")" );
|
||||
SG_LOG( SG_GENERAL, SG_DEBUG, " area type = " << area);
|
||||
} else {
|
||||
area = get_area_type( force_area_type );
|
||||
area = force_area_type;
|
||||
}
|
||||
|
||||
if ( force_linewidth < 0 ) {
|
||||
|
@ -857,7 +856,7 @@ int main( int argc, char **argv ) {
|
|||
psShape->dfZMax, psShape->dfMMax );
|
||||
#endif
|
||||
|
||||
if ( area == OceanArea ) {
|
||||
if ( is_ocean_area(area) ) {
|
||||
// interior of polygon is ocean, holes are islands
|
||||
|
||||
SG_LOG( SG_GENERAL, SG_ALERT, "Ocean area ... SKIPPING!" );
|
||||
|
@ -866,7 +865,7 @@ int main( int argc, char **argv ) {
|
|||
// all other ocean data
|
||||
SHPDestroyObject( psShape );
|
||||
continue;
|
||||
} else if ( area == VoidArea ) {
|
||||
} else if ( is_void_area(area) ) {
|
||||
// interior is ????
|
||||
|
||||
// skip for now
|
||||
|
@ -878,7 +877,7 @@ int main( int argc, char **argv ) {
|
|||
}
|
||||
SHPDestroyObject( psShape );
|
||||
continue;
|
||||
} else if ( area == NullArea ) {
|
||||
} else if ( is_null_area(area) ) {
|
||||
// interior is ????
|
||||
|
||||
// skip for now
|
||||
|
@ -896,7 +895,7 @@ int main( int argc, char **argv ) {
|
|||
// interior of polygon is assigned to force_area_type,
|
||||
// holes are preserved
|
||||
|
||||
area = get_area_type( force_area_type );
|
||||
area = force_area_type;
|
||||
}
|
||||
|
||||
switch (psShape->nSHPType) {
|
||||
|
|
|
@ -47,7 +47,6 @@ SG_USING_STD(vector);
|
|||
#include <Geometry/util.hxx>
|
||||
#include <Polygon/chop.hxx>
|
||||
#include <Polygon/index.hxx>
|
||||
#include <Polygon/names.hxx>
|
||||
#include <Polygon/polygon.hxx>
|
||||
#include <vpf/vpf.hxx>
|
||||
|
||||
|
@ -285,7 +284,7 @@ main (int argc, const char **argv)
|
|||
// Default values
|
||||
tg::Rectangle bounds(Point3D(-180, -90, 0), Point3D(180, 90, 0));
|
||||
bool invert = false;
|
||||
AreaType material_type = DefaultArea;
|
||||
string material_type = "Default";
|
||||
int width = -1; // use default
|
||||
double max_segment = 0.0; // zero = no segement splitting
|
||||
string work_dir = ".";
|
||||
|
@ -342,7 +341,7 @@ main (int argc, const char **argv)
|
|||
}
|
||||
|
||||
else if (arg.find("--material=") == 0) {
|
||||
material_type = get_area_type(arg.substr(11).c_str());
|
||||
material_type = arg.substr(11);
|
||||
argPos++;
|
||||
}
|
||||
|
||||
|
@ -437,7 +436,7 @@ main (int argc, const char **argv)
|
|||
cout << "Minimum area: " << min_area << endl;
|
||||
if (max_area > -1)
|
||||
cout << "Maximum area: " << max_area << endl;
|
||||
cout << "Material type: " << get_area_name(material_type) << endl;
|
||||
cout << "Material type: " << material_type << endl;
|
||||
if (width > -1)
|
||||
cout << "Point and line width: " << width << endl;
|
||||
for (unsigned int x = 0; x < attributes.size(); x++) {
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
#include <Geometry/util.hxx>
|
||||
#include <Polygon/chop.hxx>
|
||||
#include <Polygon/index.hxx>
|
||||
#include <Polygon/names.hxx>
|
||||
#include <Polygon/polygon.hxx>
|
||||
|
||||
#include <stdlib.h>
|
||||
|
@ -50,8 +49,7 @@ parse_point (const char * s, Point3D &p)
|
|||
static void
|
||||
add_point (SGPropertyNode_ptr node)
|
||||
{
|
||||
AreaType material =
|
||||
get_area_type(node->getStringValue("material", "Default"));
|
||||
const string& poly_type=node->getStringValue("material", "Default");
|
||||
Point3D p, dummy;
|
||||
const char * s = node->getStringValue("v");
|
||||
s = parse_point(s, p);
|
||||
|
@ -65,14 +63,13 @@ add_point (SGPropertyNode_ptr node)
|
|||
TGPolygon poly;
|
||||
tg::makePolygon(p, node->getIntValue("width", 500), poly);
|
||||
poly = tgPolygonInt(poly, bounds_poly);
|
||||
tgChopNormalPolygon(".", material, poly, false);
|
||||
tgChopNormalPolygon(".", poly_type, poly, false);
|
||||
}
|
||||
|
||||
static void
|
||||
add_line (SGPropertyNode_ptr node)
|
||||
{
|
||||
AreaType material =
|
||||
get_area_type(node->getStringValue("material", "Default"));
|
||||
const string& poly_type=node->getStringValue("material", "Default");
|
||||
const char * s = node->getStringValue("v");
|
||||
|
||||
Point3D p;
|
||||
|
@ -86,15 +83,14 @@ add_line (SGPropertyNode_ptr node)
|
|||
TGPolygon poly;
|
||||
tg::makePolygon(line, node->getIntValue("width", 10), poly);
|
||||
poly = tgPolygonInt(poly, bounds_poly);
|
||||
tgChopNormalPolygon(".", material, poly, false);
|
||||
tgChopNormalPolygon(".", poly_type, poly, false);
|
||||
}
|
||||
|
||||
static void
|
||||
add_polygon (SGPropertyNode_ptr node)
|
||||
{
|
||||
TGPolygon poly;
|
||||
AreaType material =
|
||||
get_area_type(node->getStringValue("material", "Default"));
|
||||
const string& poly_type=node->getStringValue("material", "Default");
|
||||
vector<SGPropertyNode_ptr> contour_nodes = node->getChildren("contour");
|
||||
for (unsigned int i = 0; i < contour_nodes.size(); i++) {
|
||||
SGPropertyNode_ptr contour_node = contour_nodes[i];
|
||||
|
@ -108,7 +104,7 @@ add_polygon (SGPropertyNode_ptr node)
|
|||
poly.set_hole_flag(i, contour_node->getBoolValue("hole", false));
|
||||
}
|
||||
poly = tgPolygonInt(poly, bounds_poly);
|
||||
tgChopNormalPolygon(".", material, poly, false);
|
||||
tgChopNormalPolygon(".", poly_type, poly, false);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Add table
Reference in a new issue