diff --git a/DESCRIPTION b/DESCRIPTION index 272cfca..2815987 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,10 +1,10 @@ Package: maps Title: Draw Geographical Maps -Version: 2.2-1 -Date: 2011-11-03 +Version: 2.2-2 +Date: 2011-11-09 Author: Original S code by Richard A. Becker and Allan R. Wilks. - R version by Ray Brownrigg - Enhancements by Thomas P Minka + R version by Ray Brownrigg . + Enhancements by Thomas P Minka . Description: Display of maps. Projection code and larger maps are in separate packages (mapproj and mapdata). Depends: R (>= 2.10.0) @@ -12,6 +12,6 @@ LazyLoad: yes Suggests: mapproj License: GPL-2 Maintainer: Ray Brownrigg -Packaged: 2011-11-03 03:23:57 UTC; ray +Packaged: 2011-11-08 23:37:04 UTC; ray Repository: CRAN -Date/Publication: 2011-11-03 11:48:16 +Date/Publication: 2011-11-09 08:03:02 diff --git a/MD5 b/MD5 index 3d20bfd..467f9a1 100644 --- a/MD5 +++ b/MD5 @@ -1,11 +1,11 @@ -13cf847a6d86dc9f38e0731d583a3275 *DESCRIPTION +f4282e8a52723b917f0368dbf73601ab *DESCRIPTION 012592abf4b40a8d741b299df2ded05a *NAMESPACE 80aa05ca421f4b4aafd2aa1c62e5bf2d *R/db.r 4a62baaaeb68b971eba22eb579f4e414 *R/map.r 5f0c0ab48d2ce320c4ba0d0018a57d99 *R/misc.r 89ba2eda91abd2d6fdaebfde9da3f4e9 *R/polygon.r 45bb5cad9ffc203d8e62dae784725f37 *R/smooth.r -6e753ff5cb6ed7189c4e0dcd3eb46758 *R/zzz.R +6f0c8ff18c3b1d87c3fe4687ae7da8da *R/zzz.R 6d3acd6bf8fe0501140653a66952a160 *data/canada.cities.rda 09229fd795049dfd32cba1042ae16c69 *data/county.fips.rda 35d87c916a508fe3c71c917cd1c33cb3 *data/countyMapEnv.r @@ -13,7 +13,11 @@ e905d7c3ec3746a5463aece42a29afce *data/italyMapEnv.r b8168bd40b33d5493e67a5d2f35d7e67 *data/nzMapEnv.r 8d109b47aa40edeaaa43e7406c0ea3ba *data/ozone.rda +362b6ac3137d24e14ff31545c6bc75e5 *data/state.carto.center.rda +4188c1cf58e79e9ad31f2a828bf3f1aa *data/state.cartoMapEnv.r e5e971cef422bb733644791ebdc05547 *data/state.fips.rda +0d920fc325a0cbd152019a3ef88adeb7 *data/state.vbm.center.rda +b69d31b3798c90f8daf7739755de1a93 *data/state.vbmMapEnv.r 388d3067e6c9ce642d2dafbb02b8851e *data/stateMapEnv.r 3bbbc17c88b46d5ccfc51cfdc599ce28 *data/unemp.rda 47260e722f73cdedba76a2cc1e6a3205 *data/us.cities.rda @@ -43,7 +47,9 @@ dc4256b7510c06529ade1c14c58cd5c7 *man/ozone.Rd e368efb53ad4d9a95938eb078ca68fd8 *man/polygon.Rd fc2661fa4e7119cae77f7c937205bab3 *man/smooth.map.Rd 53e2f7fe3c4166e412fdbecab22557fa *man/state.Rd -ba8d5d668beb64222ee0feecc3be1f83 *man/state.fips.Rd +c2bfc2d7a2639dbf64962901f70e4c92 *man/state.carto.Rd +fa354b69c9d9ca135a97133f00bd0024 *man/state.fips.Rd +5634c8781a38aff1c8c5867a2582b504 *man/state.vbm.Rd 4772854c8b17ec1604f5e099e4375c8a *man/us.cities.Rd f25971f020951d5260292158a6600389 *man/usa.Rd 8f319ab0ebd2fe4d3db27fea8b2e52fc *man/world.Rd @@ -51,8 +57,8 @@ dc4668c3b67ae20d466fdb60c07be88c *man/world.cities.Rd 150ee84eeb7fb26843418b9213468e88 *man/world2.Rd f684d16afeece0ab0ecdaddd67397466 *src/Gmake.c 9d0c7fa4265c2622840a930b7fa8f67a *src/Lmake.c -b166b91401f14635f63f96152a837baf *src/Makefile -5836a87ca9b464dd87c5cbf401e6344a *src/Makefile.win +7088312f20b1d127d59081a8ea4ce10c *src/Makefile +d1ebffb0e35151ea78870f20b78320d5 *src/Makefile.win ee000c17ddd154301f679ce267ed4918 *src/README 885521324ea75cdfcea9d91a5afb0ec5 *src/convert.awk 7e6373f288c239e3c4a81dd10347d2c9 *src/county.gon @@ -73,19 +79,29 @@ f7c622f74f28e328d3d65f265f0a26c3 *src/italy.gonstats 1ddcc46403193ad474b3934d046f10bf *src/italy.name 28f0356bc9bb3e0b479b9cc916930730 *src/map.h 11fb4709e58d7a684b9c48dbe54fd8b5 *src/mapget.c +8cee9d537960596124350a5aad35f91a *src/maps.def 5e9c4adf4fc41a391e3539fa708961b0 *src/nz.gon 1baecc758797af3a5db79c56f81b16be *src/nz.gonstats 750f995d19363927fdc64f1656f5e6ac *src/nz.line f4813dcc9e8ace61c3127247d89ca050 *src/nz.linestats 9f6127bc86be1670ef43b54b113a94b9 *src/nz.name 38c841a4ae31088764a4173dea9fb99d *src/smooth.c +6c92393ef3acc69f57b4f872d1c28e47 *src/state.carto.gon +db440c97b18a6344052b56e25b841f4f *src/state.carto.gonstats +165c66a04e6a98fc905ccf2a8f8ecfe2 *src/state.carto.line +89c9babeeb2c2ba537e6c0948abcd038 *src/state.carto.linestats +55f43c464d795dfd9f5c30bd1326a431 *src/state.carto.name efbdb5e7346ddaae0314aff52661b45f *src/state.gon 8a5f0b214eb18898570b3d3265690c7b *src/state.gonstats 9ec76bff7df86d5e1d1e62b231f57d8c *src/state.line 1cf5afc6966bb36f5bc82eea4b2335c6 *src/state.linestats 54a14292aa6880f6e3760b8f6c559a85 *src/state.name -11c733a2db4704c9e2f13942a4c998fc *src/thin.c -7565197b7181346e1632535bfc36650a *src/thin.c.orig +6c92393ef3acc69f57b4f872d1c28e47 *src/state.vbm.gon +db440c97b18a6344052b56e25b841f4f *src/state.vbm.gonstats +85b0e36ec94dcf8b1b5b39ae324106b1 *src/state.vbm.line +69fd7440de022ae8ff0874b0aa441de7 *src/state.vbm.linestats +55f43c464d795dfd9f5c30bd1326a431 *src/state.vbm.name +7565197b7181346e1632535bfc36650a *src/thin.c f298493e3329a78ce0931272d511b60f *src/usa.gon 1c1041f7228b105eaaa93d8b3a9bf8d1 *src/usa.gonstats 64612e351ce91a03a2040b0edd64d295 *src/usa.line diff --git a/R/zzz.R b/R/zzz.R index db98d67..7ae0c9d 100755 --- a/R/zzz.R +++ b/R/zzz.R @@ -1,6 +1,4 @@ .onLoad <- function(lib, pkg) { - if(!exists("Sys.setenv", envir = baseenv())) - Sys.setenv <- Sys.putenv if (Sys.getenv("R_MAP_DATA_DIR") == "") Sys.setenv("R_MAP_DATA_DIR"=paste(lib, pkg, "mapdata/", sep="/")) library.dynam("maps", pkg, lib) diff --git a/data/state.carto.center.rda b/data/state.carto.center.rda new file mode 100644 index 0000000..0a835b5 Binary files /dev/null and b/data/state.carto.center.rda differ diff --git a/data/state.cartoMapEnv.r b/data/state.cartoMapEnv.r new file mode 100644 index 0000000..9cba662 --- /dev/null +++ b/data/state.cartoMapEnv.r @@ -0,0 +1 @@ +state.cartoMapEnv <- "R_MAP_DATA_DIR" diff --git a/data/state.vbm.center.rda b/data/state.vbm.center.rda new file mode 100644 index 0000000..6aac25a Binary files /dev/null and b/data/state.vbm.center.rda differ diff --git a/data/state.vbmMapEnv.r b/data/state.vbmMapEnv.r new file mode 100644 index 0000000..8747981 --- /dev/null +++ b/data/state.vbmMapEnv.r @@ -0,0 +1 @@ +state.vbmMapEnv <- "R_MAP_DATA_DIR" diff --git a/man/state.carto.Rd b/man/state.carto.Rd new file mode 100644 index 0000000..84d1dc5 --- /dev/null +++ b/man/state.carto.Rd @@ -0,0 +1,49 @@ +\name{state.carto} +\docType{data} +\alias{state.carto} +\alias{state.cartoMapEnv} +\alias{state.carto.center} +\title{ +United States State Population Cartogram Map +} +\usage{ +data(stateMapEnv) +data(state.carto.center) +} +\description{ + +This database produces a cartogram of the states of the United States +mainland based on CartoDraw, roughly proportional to population (see +references). + +\code{state.carto.center} are coordinates of the state centers +for annotation purposes. +} +\format{ +The data file is merely an assignment to a character string which +specifies the name of an environment variable which contains the +base location of the binary files used by the map drawing functions. +This environment variable (\code{R_MAP_DATA_DIR} for the datasets in the +maps package) is set at package load time \emph{if it does not +already exist}. Hence setting the environment variable before loading +the package can override the default location of the binary datasets. +} +\seealso{ +\code{\link{map}}. +} +\examples{ +map('state.carto', fill = TRUE, col = palette()) +} +\references{ +Richard A. Becker, and Allan R. Wilks, +"Maps in S", +\emph{AT\&T Bell Laboratories Statistics Research Report [93.2], 1993.} + +Richard A. Becker, and Allan R. Wilks, +"Constructing a Geographical Database", +\emph{AT\&T Bell Laboratories Statistics Research Report [95.2], 1995.} + +CartoDraw, +\url{http://infovis.uni-konstanz.de/~panse/CartoDraw/CartoDrawIndex.php} +} +\keyword{datasets} diff --git a/man/state.fips.Rd b/man/state.fips.Rd index 9212730..111aec5 100644 --- a/man/state.fips.Rd +++ b/man/state.fips.Rd @@ -10,9 +10,9 @@ A database matching FIPS codes to maps package state names. \usage{data(state.fips)} \format{ A list with 6 components, namely "fips", "ssa", "region", division", -"abb" and "polyname", containing the FIPS, SSA, REGION and DIVISION -numbers, the standard state abbreviation and the the respective state -polygon name. +"abb" and "polyname", containing the US Census Bureau FIPS, SSA, REGION +and DIVISION numbers, the standard state abbreviation and the respective +state polygon name. } \seealso{ \code{\link{county.fips}} diff --git a/man/state.vbm.Rd b/man/state.vbm.Rd new file mode 100644 index 0000000..37146c4 --- /dev/null +++ b/man/state.vbm.Rd @@ -0,0 +1,51 @@ +\name{state.vbm} +\docType{data} +\alias{state.vbm} +\alias{state.vbmMapEnv} +\alias{state.vbm.center} +\title{ +United States State Visibility Base Map +} +\usage{ +data(stateMapEnv) +data(state.vbm.center) +} +\description{ + +This database produces a map of the states of the United States +mainland. The Visibility Base Map was created by Mark Monmonier +to provide simplified state shapes with sufficient areas to allow +annotations in even the small states. + +\code{state.vbm.center} are coordinates of the state centers +for annotation purposes. +} +\format{ +The data file is merely an assignment to a character string which +specifies the name of an environment variable which contains the +base location of the binary files used by the map drawing functions. +This environment variable (\code{R_MAP_DATA_DIR} for the datasets in the +maps package) is set at package load time \emph{if it does not +already exist}. Hence setting the environment variable before loading +the package can override the default location of the binary datasets. +} +\seealso{ +\code{\link{map}}. +} +\examples{ +map('state.vbm', fill = TRUE, col = palette()) +} +\references{ +Richard A. Becker, and Allan R. Wilks, +"Maps in S", +\emph{AT\&T Bell Laboratories Statistics Research Report [93.2], 1993.} + +Richard A. Becker, and Allan R. Wilks, +"Constructing a Geographical Database", +\emph{AT\&T Bell Laboratories Statistics Research Report [95.2], 1995.} + +Mark Monmonier and George Schnell, +"The Study of Population", +\emph{Elements, Patterns, Processes. Charles E. Merrill. Columbus, OH. 1982.} +} +\keyword{datasets} diff --git a/src/Makefile b/src/Makefile index 2fd87fb..e014f19 100644 --- a/src/Makefile +++ b/src/Makefile @@ -11,9 +11,9 @@ OBJS = mapget.o \ smooth.o \ thin.o -GDATA = county.G state.G usa.G nz.G world.G world2.G italy.G france.G -LDATA = county.L state.L usa.L nz.L world.L world2.L italy.L france.L -NDATA = county.N state.N usa.N nz.N world.N world2.N italy.N france.N +GDATA = county.G state.G usa.G nz.G world.G world2.G italy.G france.G state.vbm.G state.carto.G +LDATA = county.L state.L usa.L nz.L world.L world2.L italy.L france.L state.vbm.L state.carto.L +NDATA = county.N state.N usa.N nz.N world.N world2.N italy.N france.N state.vbm.N state.carto.N .line.L: @$(MKDIR) -p ../inst/mapdata @@ -30,6 +30,14 @@ NDATA = county.N state.N usa.N nz.N world.N world2.N italy.N france.N all: gdata ndata $(PKGNAME)$(SHLIB_EXT) +state.carto.L: state.carto.line state.carto.linestats Lmake + @$(MKDIR) -p ../inst/mapdata + ./Lmake 0 p b state.carto.line state.carto.linestats ../inst/mapdata/state.carto.L + +state.vbm.L: state.vbm.line state.vbm.linestats Lmake + @$(MKDIR) -p ../inst/mapdata + ./Lmake 0 p b state.vbm.line state.vbm.linestats ../inst/mapdata/state.vbm.L + gdata: Gmake ldata $(MAKE) $(GDATA) diff --git a/src/Makefile.win b/src/Makefile.win index 9062a91..80be8e1 100644 --- a/src/Makefile.win +++ b/src/Makefile.win @@ -14,9 +14,9 @@ OBJS = mapget.o \ smooth.o \ thin.o -GDATA = county.G state.G usa.G nz.G world.G world2.G italy.G france.G -LDATA = county.L state.L usa.L nz.L world.L world2.L italy.L france.L -NDATA = county.N state.N usa.N nz.N world.N world2.N italy.N france.N +GDATA = county.G state.G usa.G nz.G world.G world2.G italy.G france.G state.vbm.G state.carto.G +LDATA = county.L state.L usa.L nz.L world.L world2.L italy.L france.L state.vbm.L state.carto.L +NDATA = county.N state.N usa.N nz.N world.N world2.N italy.N france.N state.vbm.N state.carto.N .line.L: @$(MKDIR) -p ../inst/mapdata @@ -33,6 +33,14 @@ NDATA = county.N state.N usa.N nz.N world.N world2.N italy.N france.N all: ../libs$(R_ARCH)/$(DLLNAME).dll ldata gdata ndata +state.carto.L: state.carto.line state.carto.linestats Lmake + @$(MKDIR) -p ../inst/mapdata + ./Lmake 0 p b state.carto.line state.carto.linestats ../inst/mapdata/state.carto.L + +state.vbm.L: state.vbm.line state.vbm.linestats Lmake + @$(MKDIR) -p ../inst/mapdata + ./Lmake 0 p b state.vbm.line state.vbm.linestats ../inst/mapdata/state.vbm.L + gdata: Gmake ldata $(MAKE) -f Makefile.win $(GDATA) diff --git a/src/maps.def b/src/maps.def new file mode 100755 index 0000000..88c6896 --- /dev/null +++ b/src/maps.def @@ -0,0 +1,6 @@ +EXPORTS + _i686.get_pc_thunk.bx + _i686.get_pc_thunk.cx + _i686.get_pc_thunk.bx + _i686.get_pc_thunk.bx + _i686.get_pc_thunk.cx diff --git a/src/state.carto.gon b/src/state.carto.gon new file mode 100644 index 0000000..cd48a21 --- /dev/null +++ b/src/state.carto.gon @@ -0,0 +1,100 @@ + 1 +EOR + 2 +EOR + 3 +EOR + 4 +EOR + 5 +EOR + 6 +EOR + 7 +EOR + 8 +EOR + 9 +EOR + 10 +EOR + 11 +EOR + 12 +EOR + 13 +EOR + 14 +EOR + 15 +EOR + 16 +EOR + 17 +EOR + 18 +EOR + 19 +EOR + 20 +EOR + 21 +EOR + 22 +EOR + 23 +EOR + 24 +EOR + 25 +EOR + 26 +EOR + 27 +EOR + 28 +EOR + 29 +EOR + 30 +EOR + 31 +EOR + 32 +EOR + 33 +EOR + 34 +EOR + 35 +EOR + 36 +EOR + 37 +EOR + 38 +EOR + 39 +EOR + 40 +EOR + 41 +EOR + 42 +EOR + 43 +EOR + 44 +EOR + 45 +EOR + 46 +EOR + 47 +EOR + 48 +EOR + 49 +EOR + 50 +EOR diff --git a/src/state.carto.gonstats b/src/state.carto.gonstats new file mode 100644 index 0000000..4443696 --- /dev/null +++ b/src/state.carto.gonstats @@ -0,0 +1 @@ +50 1 diff --git a/src/state.carto.line b/src/state.carto.line new file mode 100644 index 0000000..c9f7b1c --- /dev/null +++ b/src/state.carto.line @@ -0,0 +1,524 @@ +1 0 +5.832 5.8024 +5.7456 6.4288 +5.3064 6.4648 +5.2776 5.8744 +5.3712 5.8168 +5.832 5.8024 +EOR +0 2 +0.9864 9.3448 +1.1808 9.3304 +1.1592 9.028 +1.116 9.2008 +1.0296 9.0928 +0.9864 9.3448 +EOR +0 3 +2.4192 6.7528 +2.556 7.264 +2.4408 7.48 +2.4624 7.6168 +2.7648 7.5952 +2.8224 6.8824 +2.6496 6.6952 +2.4192 6.7528 +EOR +4 0 +4.788 6.58 +4.8456 6.7312 +4.716 6.7672 +4.7808 6.8752 +4.0824 7.2784 +4.2552 6.8968 +4.392 6.8392 +4.392 6.6952 +4.788 6.58 +EOR +5 0 +2.376 6.796 +2.52 7.2712 +2.1096 7.8832 +2.1096 8.0848 +0.9216 8.1208 +0.3744 7.6816 +0.8856 6.6664 +1.2672 6.4576 +1.6056 6.22 +2.376 6.796 +EOR +6 0 +2.808 7.66 +3.1752 7.5808 +3.3552 7.5952 +3.3624 8.1856 +2.8152 8.2 +2.808 7.66 +EOR +7 0 +9.1512 7.948 +9.1872 8.3152 +8.6256 8.344 +8.604 7.8616 +9.1512 7.948 +EOR +8 0 +8.0928 6.8536 +7.8408 7.2784 +7.9056 7.4872 +7.8048 7.48 +7.8552 6.8464 +8.0928 6.8536 +EOR +9 0 +5.4 5.788 +5.4072 5.6728 +5.6304 5.6296 +5.7888 5.4568 +6.0408 5.5216 +6.3432 5.2048 +6.4512 4.6072 +6.9552 3.7864 +7.1064 3.7432 +7.272 3.9448 +7.2864 4.3696 +7.1136 4.8808 +6.84 5.608 +6.6096 5.608 +5.904 5.68 +5.8608 5.7664 +5.4 5.788 +EOR +10 0 +6.84 5.7592 +6.2784 6.4 +5.7672 6.4432 +5.8968 5.7448 +6.6456 5.6296 +6.6816 5.716 +6.8256 5.6584 +6.84 5.7592 +EOR +0 11 +0.6624 5.9752 +0.8784 6.1192 +0.9864 6.0832 +1.008 5.9896 +0.828 5.896 +0.6624 5.9752 +EOR +12 0 +2.3976 8.5888 +2.412 8.1496 +2.772 8.1568 +2.772 8.2216 +2.3976 8.5888 +EOR +0 13 +5.2848 7.3432 +5.1264 6.9976 +4.9248 6.9328 +4.6224 7.2856 +4.6512 7.4584 +4.536 7.5088 +4.3272 7.7968 +4.3416 7.9768 +4.6224 8.3368 +5.1696 8.3944 +5.2272 8.2216 +5.2848 7.3432 +EOR +0 14 +5.7168 8.2216 +5.7096 7.2928 +5.5584 7.1272 +5.436 7.1344 +5.1912 7.0696 +5.3064 7.3288 +5.2776 8.2072 +5.7168 8.2216 +EOR +15 0 +4.32 7.9912 +4.3776 8.1712 +4.5648 8.308 +4.4424 8.3872 +3.6792 8.3296 +3.7512 8.056 +4.32 7.9912 +EOR +16 0 +3.4416 7.5736 +3.9456 7.5376 +3.9528 7.7608 +3.8664 7.912 +3.4056 7.9192 +3.4416 7.5736 +EOR +0 17 +6.228 7.0192 +6.1632 7.156 +5.9904 7.1056 +5.724 7.2352 +5.5584 7.0768 +5.1408 6.9976 +4.9608 6.9256 +4.9536 6.8536 +5.1552 6.8896 +5.9976 6.8392 +6.228 7.0192 +EOR +0 18 +5.1336 5.86 +5.1336 5.7232 +4.4568 5.8744 +4.536 6.1984 +4.392 6.6376 +4.7736 6.508 +4.824 6.3712 +4.7088 6.1336 +5.1336 5.86 +EOR +19 0 +9.144 9.1216 +9.4464 9.2872 +9.3672 9.3448 +9.36 9.5392 +9.216 9.5968 +9.0936 9.424 +9.144 9.1216 +EOR +0 20 +8.1144 6.796 +8.0496 6.5944 +7.8048 6.5368 +7.7112 6.94 +7.6968 6.7672 +7.4016 7.048 +7.2648 7.3288 +7.0776 7.48 +7.776 7.4584 +7.8264 6.8176 +8.1144 6.796 +EOR +0 21 +8.7552 8.9776 +9.2016 9.0136 +9.4032 8.8552 +9.3816 8.6032 +9.6336 8.1856 +9.7776 8.1856 +9.7776 8.0488 +9.4968 8.092 +9.3816 8.3296 +8.6256 8.3944 +8.7552 8.9776 +EOR +22 0 +5.436 8.272 +6.1992 8.3008 +6.3936 8.5744 +6.4512 8.848 +6.2928 9.0352 +6.0048 9.1936 +6.3216 9.2008 +6.156 9.3016 +5.7744 9.2584 +5.472 9.3448 +4.8312 9.0424 +5.2056 8.8912 +5.256 8.8048 +5.4288 9.0712 +5.8032 9.1936 +5.976 9.136 +5.7456 8.9488 +5.6448 8.9992 +5.4792 8.7184 +5.5224 8.5024 +5.436 8.272 +EOR +23 0 +3.6576 8.3872 +4.4136 8.416 +4.2912 8.5456 +4.32 8.7688 +4.5216 8.9776 +3.888 8.9056 +3.888 8.8192 +3.564 8.6248 +3.6576 8.3872 +EOR +24 0 +5.2416 5.9176 +5.2632 6.4864 +4.824 6.5656 +4.86 6.3568 +4.7448 6.1552 +5.076 6.112 +5.1336 5.932 +5.2416 5.9176 +EOR +25 0 +4.8672 6.7816 +4.9176 6.8896 +4.572 7.2928 +4.608 7.4656 +4.4712 7.48 +4.284 7.8256 +4.2696 7.9768 +3.78 8.0128 +3.9816 7.7752 +3.9816 7.3648 +4.824 6.904 +4.8024 6.8032 +4.8672 6.7816 +EOR +0 26 +2.4984 8.5672 +3.0672 8.5384 +3.0744 8.4088 +2.7144 8.38 +2.6712 8.3368 +2.4984 8.5672 +EOR +27 0 +3.3984 7.9624 +3.7728 7.9624 +3.6792 8.2504 +3.1176 8.3008 +3.1104 8.2144 +3.3912 8.1928 +3.3984 7.9624 +EOR +28 0 +2.4048 7.5664 +2.4264 8.0992 +2.1384 8.092 +2.1528 7.8976 +2.4048 7.5664 +EOR +29 0 +8.9856 9.4168 +8.8776 9.208 +8.8416 9.0208 +9.1512 9.0424 +9.0864 9.1432 +9.0576 9.4024 +8.9856 9.4168 +EOR +0 30 +8.1 8.0776 +8.4744 7.8616 +8.4024 7.732 +8.4312 7.6096 +8.6832 7.5592 +8.6616 7.1128 +8.1864 6.6232 +8.208 6.8608 +7.8552 7.2856 +7.9416 7.5016 +8.0928 7.6096 +7.9488 7.8112 +7.9704 7.9696 +8.1 8.0776 +EOR +31 0 +2.844 7.0768 +3.1464 7.084 +3.1608 7.5448 +2.8152 7.6096 +2.844 7.0768 +EOR +0 32 +8.7264 9.3808 +8.7264 8.92 +8.568 8.4088 +8.5536 7.8904 +8.1072 8.1208 +7.92 8.3872 +6.8328 8.416 +7.0488 8.6392 +6.9984 8.8912 +7.632 8.9128 +7.8192 9.064 +7.74 9.172 +8.1576 9.4168 +8.7264 9.3808 +EOR +0 33 +7.6824 6.6952 +7.7688 6.364 +7.308 6.1264 +7.0632 6.3496 +6.8256 6.3568 +6.768 6.472 +6.372 6.4576 +6.0984 6.4936 +6.4872 6.7456 +7.6824 6.6952 +EOR +0 34 +3.06 8.5384 +3.5352 8.6176 +3.5784 8.4664 +3.0816 8.4376 +3.06 8.5384 +EOR +0 35 +6.7032 8.3152 +6.7176 7.7752 +6.5016 7.3648 +6.2424 7.1056 +6.156 7.1776 +5.9616 7.1416 +5.7456 7.2712 +5.7672 8.2144 +6.2136 8.2432 +6.7032 8.3152 +EOR +36 0 +4.2192 6.9184 +4.14 7.1632 +3.9312 7.3432 +3.9384 7.4872 +3.204 7.5448 +3.204 7.4872 +3.6504 7.48 +3.6432 7.0624 +3.888 6.9472 +4.2192 6.9184 +EOR +37 0 +0.9144 8.1856 +0.936 8.4088 +1.152 8.2648 +2.376 8.3512 +2.3616 8.1496 +0.9144 8.1856 +EOR +0 38 +6.7824 8.3656 +7.884 8.3368 +8.064 8.1352 +7.9416 7.984 +7.8984 7.804 +8.0424 7.624 +7.7976 7.5232 +6.7464 7.5376 +6.7824 8.3656 +EOR +0 39 +9.2088 7.9552 +9.2232 8.308 +9.3528 8.308 +9.4536 8.0848 +9.432 7.9912 +9.2088 7.9552 +EOR +40 0 +6.8832 5.7664 +7.2576 6.0904 +7.0488 6.2992 +6.8256 6.3064 +6.7536 6.4072 +6.372 6.4 +6.732 5.9968 +6.8832 5.7664 +EOR +41 0 +3.0888 8.4016 +3.1104 8.3296 +3.6432 8.308 +3.564 8.4304 +3.0888 8.4016 +EOR +0 42 +4.9248 6.796 +5.1768 6.832 +6.4512 6.7528 +6.0552 6.4936 +4.8528 6.6016 +4.9248 6.796 +EOR +43 0 +2.88 7.0408 +3.1248 6.3352 +3.3264 6.1192 +3.3912 6.2128 +3.8304 5.5 +4.104 5.4064 +4.1256 5.6512 +4.428 5.9104 +4.4856 6.2128 +4.3704 6.4072 +4.356 6.832 +3.6504 6.9544 +3.6216 7.4656 +3.1824 7.4656 +3.1824 7.084 +2.88 7.0408 +EOR +44 0 +2.7792 7.66 +2.7792 8.1928 +2.4768 8.1064 +2.4624 7.6744 +2.7792 7.66 +EOR +45 0 +8.7624 9.388 +8.748 8.9992 +8.8056 9.0064 +8.8488 9.2296 +8.964 9.3808 +8.7624 9.388 +EOR +46 0 +7.6608 6.7312 +7.3656 7.0192 +7.1424 7.3792 +6.9768 7.4296 +6.5592 6.9904 +6.0408 6.8464 +6.9696 6.7384 +7.6608 6.7312 +EOR +47 0 +2.376 8.3872 +2.3688 8.6032 +1.2528 8.74 +1.2528 8.596 +0.8208 8.7256 +0.9288 8.452 +1.188 8.308 +2.376 8.3872 +EOR +0 48 +6.264 7.0696 +6.4872 7.3072 +6.7248 7.66 +6.7248 7.4944 +6.8184 7.4656 +6.7968 7.2712 +6.6888 7.2928 +6.5376 7.0264 +6.336 6.976 +6.264 7.0696 +EOR +49 0 +4.4784 8.3944 +5.1912 8.4448 +5.22 8.7904 +4.7952 8.992 +4.4352 8.8768 +4.3344 8.7112 +4.3272 8.5744 +4.4784 8.3944 +EOR +0 50 +2.8296 8.236 +2.8008 8.3368 +3.0816 8.344 +3.0744 8.2648 +2.8296 8.236 +EOR diff --git a/src/state.carto.linestats b/src/state.carto.linestats new file mode 100644 index 0000000..e9dd567 --- /dev/null +++ b/src/state.carto.linestats @@ -0,0 +1 @@ +50 45 diff --git a/src/state.carto.name b/src/state.carto.name new file mode 100644 index 0000000..9871bfe --- /dev/null +++ b/src/state.carto.name @@ -0,0 +1,50 @@ +Alabama 1 +Alaska 2 +Arizona 3 +Arkansas 4 +California 5 +Colorado 6 +Connecticut 7 +Delaware 8 +Florida 9 +Georgia 10 +Hawaii 11 +Idaho 12 +Illinois 13 +Indiana 14 +Iowa 15 +Kansas 16 +Kentucky 17 +Louisiana 18 +Maine 19 +Maryland 20 +Massachusetts 21 +Michigan 22 +Minnesota 23 +Mississippi 24 +Missouri 25 +Montana 26 +Nebraska 27 +Nevada 28 +New Hampshire 29 +New Jersey 30 +New Mexico 31 +New York 32 +North Carolina 33 +North Dakota 34 +Ohio 35 +Oklahoma 36 +Oregon 37 +Pennsylvania 38 +Rhode Island 39 +South Carolina 40 +South Dakota 41 +Tennessee 42 +Texas 43 +Utah 44 +Vermont 45 +Virginia 46 +Washington 47 +West Virginia 48 +Wisconsin 49 +Wyoming 50 diff --git a/src/state.vbm.gon b/src/state.vbm.gon new file mode 100644 index 0000000..cd48a21 --- /dev/null +++ b/src/state.vbm.gon @@ -0,0 +1,100 @@ + 1 +EOR + 2 +EOR + 3 +EOR + 4 +EOR + 5 +EOR + 6 +EOR + 7 +EOR + 8 +EOR + 9 +EOR + 10 +EOR + 11 +EOR + 12 +EOR + 13 +EOR + 14 +EOR + 15 +EOR + 16 +EOR + 17 +EOR + 18 +EOR + 19 +EOR + 20 +EOR + 21 +EOR + 22 +EOR + 23 +EOR + 24 +EOR + 25 +EOR + 26 +EOR + 27 +EOR + 28 +EOR + 29 +EOR + 30 +EOR + 31 +EOR + 32 +EOR + 33 +EOR + 34 +EOR + 35 +EOR + 36 +EOR + 37 +EOR + 38 +EOR + 39 +EOR + 40 +EOR + 41 +EOR + 42 +EOR + 43 +EOR + 44 +EOR + 45 +EOR + 46 +EOR + 47 +EOR + 48 +EOR + 49 +EOR + 50 +EOR diff --git a/src/state.vbm.gonstats b/src/state.vbm.gonstats new file mode 100644 index 0000000..4443696 --- /dev/null +++ b/src/state.vbm.gonstats @@ -0,0 +1 @@ +50 1 diff --git a/src/state.vbm.line b/src/state.vbm.line new file mode 100644 index 0000000..cfc8fd7 --- /dev/null +++ b/src/state.vbm.line @@ -0,0 +1,494 @@ +1 0 +89.0 34.0 +96.0 34.0 +98 20 +91 20 +91.0 16.0 +89.0 17.0 +89.0 34.0 +EOR +2 0 +9.0 26.0 +16.0 23.0 +16.0 13.0 +13.0 15.0 +2.0 8.0 +7.0 13.0 +4.0 15.0 +7.0 18.0 +4.0 18.0 +4 20 +7.0 19.0 +5.0 22.0 +9.0 26.0 +EOR +3 0 +27.0 43.0 +38.0 43.0 +38.0 23.0 +32.0 23.0 +25.0 27.0 +25.0 39.0 +27.0 39.0 +27.0 43.0 +EOR +4 0 +70 40 +79 40 +79.0 38.0 +82.0 38.0 +80.0 28.0 +73.0 28.0 +73 30 +70.0 31.0 +70 40 +EOR +5 0 +1.0 61.0 +13.0 61.0 +13.0 51.0 +24.0 39.0 +24.0 27.0 +20.0 27.0 +20.0 29.0 +12.0 33.0 +1.0 55.0 +1.0 61.0 +EOR +6 0 +39.0 58.0 +53.0 58.0 +53.0 44.0 +39.0 44.0 +39.0 58.0 +EOR +7 0 +136.0 69.0 +142.0 69.0 +142.0 64.0 +137.0 63.0 +136.0 64.0 +136.0 69.0 +EOR +8 0 +128.0 57.0 +132.0 51.0 +132.0 49.0 +127.0 49.0 +127.0 55.0 +128.0 57.0 +EOR +9 0 +92.0 19.0 +97.0 19.0 +99.0 18.0 +108.0 18.0 +112.0 6.0 +109.0 1.0 +103.0 5.0 +102.0 13.0 +100.0 16.0 +92.0 16.0 +92.0 19.0 +EOR +10 0 +97.0 34.0 +101.0 34.0 +102.0 33.0 +109.0 23.0 +108.0 19.0 +99.0 19.0 +97.0 34.0 +EOR +11 0 +38.0 12.0 +41 10 +40.0 5.0 +35.0 2.0 +32.0 7.0 +38.0 12.0 +EOR +12 0 +19.0 91.0 +21.0 91.0 +21.0 87.0 +29.0 72.0 +33.0 72.0 +33.0 62.0 +19.0 62.0 +19.0 91.0 +EOR +13 0 +79.0 66.0 +84.0 66.0 +84.0 63.0 +86.0 63.0 +86.0 46.0 +84.0 44.0 +78.0 55.0 +80.0 64.0 +79.0 66.0 +EOR +14 0 +87.0 63.0 +95.0 63.0 +95.0 51.0 +88.0 47.0 +87.0 47.0 +87.0 63.0 +EOR +15 0 +65 70 +76 70 +79.0 64.0 +78 60 +77.0 58.0 +69.0 58.0 +65.0 67.0 +65 70 +EOR +16 0 +54.0 55.0 +68.0 55.0 +69.0 52.0 +69.0 44.0 +54.0 44.0 +54.0 55.0 +EOR +17 0 +95 50 +96 50 +101.0 48.0 +103.0 48.0 +105.0 45.0 +101.0 41.0 +84.0 41.0 +84.0 43.0 +95 50 +EOR +18 0 +73.0 27.0 +80.0 27.0 +79.0 21.0 +83.0 21.0 +85.0 12.0 +73.0 15.0 +73.0 27.0 +EOR +19 0 +147.0 97.0 +152.0 93.0 +153.0 83.0 +146.0 76.0 +143 90 +147.0 97.0 +EOR +20 0 +113.0 55.0 +126.0 55.0 +126.0 48.0 +132.0 48.0 +127.0 44.0 +119.0 51.0 +113.0 51.0 +113.0 55.0 +EOR +21 0 +136.0 74.0 +146.0 74.0 +149.0 72.0 +150.0 73.0 +152.0 73.0 +152.0 66.0 +148.0 65.0 +148 70 +136 70 +136.0 74.0 +EOR +22 0 +84 90 +93.0 89.0 +98.0 84.0 +94.0 84.0 +99.0 79.0 +98.0 75.0 +101.0 79.0 +101.0 71.0 +98.0 64.0 +90.0 64.0 +90.0 79.0 +94.0 84.0 +90.0 84.0 +88.0 81.0 +80.0 86.0 +84 90 +EOR +23 0 +64.0 91.0 +81.0 91.0 +74.0 84.0 +74.0 76.0 +76.0 71.0 +65.0 71.0 +65.0 79.0 +64.0 91.0 +EOR +24 0 +83.0 34.0 +88.0 34.0 +88.0 17.0 +85.0 17.0 +84.0 22.0 +80.0 22.0 +82.0 33.0 +83.0 34.0 +EOR +25 0 +69.0 57.0 +77.0 57.0 +77.0 55.0 +83.0 44.0 +82.0 39.0 +80.0 39.0 +80.0 41.0 +70.0 41.0 +70.0 52.0 +69.0 57.0 +EOR +26 0 +22.0 91.0 +47.0 91.0 +47.0 76.0 +33.0 76.0 +33.0 73.0 +30.0 73.0 +22.0 88.0 +22.0 91.0 +EOR +27 0 +48.0 66.0 +60.0 66.0 +64.0 65.0 +65.0 64.0 +68.0 56.0 +54.0 56.0 +54.0 59.0 +48.0 59.0 +48.0 66.0 +EOR +28 0 +14.0 61.0 +26.0 61.0 +26 40 +25 40 +14.0 52.0 +14.0 61.0 +EOR +29 0 +142.0 89.0 +145.0 75.0 +139.0 75.0 +142.0 89.0 +EOR +30 0 +132.0 66.0 +136.0 62.0 +136.0 54.0 +133.0 52.0 +130.0 58.0 +131 60 +129.0 64.0 +132.0 66.0 +EOR +31 0 +39.0 43.0 +51.0 43.0 +51.0 25.0 +42.0 25.0 +42.0 23.0 +39.0 23.0 +39.0 43.0 +EOR +32 0 +130.0 89.0 +135.0 89.0 +135.0 64.0 +130 70 +113 70 +113.0 72.0 +115.0 73.0 +115.0 77.0 +125.0 77.0 +125.0 84.0 +130.0 89.0 +EOR +33 0 +107 40 +127 40 +126.0 37.0 +117 30 +112.0 35.0 +101.0 35.0 +107 40 +EOR +34 0 +48.0 91.0 +63.0 91.0 +64.0 79.0 +48.0 79.0 +48.0 91.0 +EOR +35 0 +109.0 68.0 +109.0 59.0 +108.0 57.0 +103.0 49.0 +102.0 49.0 +96.0 51.0 +96.0 63.0 +103.0 63.0 +109.0 68.0 +EOR +36 0 +52.0 43.0 +69.0 43.0 +69.0 31.0 +57.0 35.0 +57 40 +52 40 +52.0 43.0 +EOR +37 0 +3.0 77.0 +5.0 77.0 +5.0 75.0 +15.0 77.0 +18.0 77.0 +18.0 62.0 +1.0 62.0 +1.0 67.0 +3.0 77.0 +EOR +38 0 +112.0 71.0 +112.0 69.0 +129.0 69.0 +131.0 67.0 +128.0 65.0 +128.0 64.0 +130 60 +126.0 56.0 +110.0 56.0 +110.0 69.0 +112.0 71.0 +EOR +39 0 +143.0 69.0 +147.0 69.0 +147.0 65.0 +143.0 64.0 +143.0 69.0 +EOR +40 0 +103.0 34.0 +111.0 34.0 +117.0 28.0 +110.0 24.0 +103.0 34.0 +EOR +41 0 +48.0 78.0 +64.0 78.0 +64.0 66.0 +60.0 67.0 +48.0 67.0 +48.0 78.0 +EOR +42 0 +84 40 +105 40 +99.0 35.0 +83.0 35.0 +84 40 +EOR +43 0 +52.0 39.0 +56.0 39.0 +56.0 34.0 +72.0 29.0 +72.0 14.0 +67.0 9.0 +67.0 2.0 +61.0 5.0 +57.0 14.0 +52.0 14.0 +43.0 24.0 +52.0 24.0 +52.0 39.0 +EOR +44 0 +27.0 61.0 +33.0 61.0 +33.0 58.0 +38.0 58.0 +38.0 44.0 +27.0 44.0 +27.0 61.0 +EOR +45 0 +136.0 89.0 +141.0 89.0 +138.0 75.0 +136.0 75.0 +136.0 89.0 +EOR +46 0 +118 50 +127.0 43.0 +125.0 41.0 +102.0 41.0 +105.0 44.0 +112.0 44.0 +117.0 49.0 +118 50 +EOR +47 0 +7.0 91.0 +18.0 91.0 +18.0 78.0 +14.0 78.0 +6.0 76.0 +6.0 78.0 +3.0 78.0 +1.0 89.0 +7.0 89.0 +7.0 91.0 +EOR +48 0 +109.0 57.0 +109.0 55.0 +112.0 55.0 +112 50 +116 50 +111.0 45.0 +106.0 45.0 +104.0 49.0 +109.0 57.0 +EOR +49 0 +75.0 84.0 +81.0 84.0 +88 80 +85.0 76.0 +85.0 67.0 +79.0 67.0 +75.0 76.0 +75.0 84.0 +EOR +50 0 +34.0 75.0 +47.0 75.0 +47.0 59.0 +34.0 59.0 +34.0 75.0 +EOR diff --git a/src/state.vbm.linestats b/src/state.vbm.linestats new file mode 100644 index 0000000..c40afb9 --- /dev/null +++ b/src/state.vbm.linestats @@ -0,0 +1 @@ +50 35 diff --git a/src/state.vbm.name b/src/state.vbm.name new file mode 100644 index 0000000..9871bfe --- /dev/null +++ b/src/state.vbm.name @@ -0,0 +1,50 @@ +Alabama 1 +Alaska 2 +Arizona 3 +Arkansas 4 +California 5 +Colorado 6 +Connecticut 7 +Delaware 8 +Florida 9 +Georgia 10 +Hawaii 11 +Idaho 12 +Illinois 13 +Indiana 14 +Iowa 15 +Kansas 16 +Kentucky 17 +Louisiana 18 +Maine 19 +Maryland 20 +Massachusetts 21 +Michigan 22 +Minnesota 23 +Mississippi 24 +Missouri 25 +Montana 26 +Nebraska 27 +Nevada 28 +New Hampshire 29 +New Jersey 30 +New Mexico 31 +New York 32 +North Carolina 33 +North Dakota 34 +Ohio 35 +Oklahoma 36 +Oregon 37 +Pennsylvania 38 +Rhode Island 39 +South Carolina 40 +South Dakota 41 +Tennessee 42 +Texas 43 +Utah 44 +Vermont 45 +Virginia 46 +Washington 47 +West Virginia 48 +Wisconsin 49 +Wyoming 50 diff --git a/src/thin.c b/src/thin.c index 5263127..be93ffa 100644 --- a/src/thin.c +++ b/src/thin.c @@ -1,6 +1,12 @@ #include "R.h" #include "map.h" +#define INIT(a) a.begin = -PI; a.end = PI +#define INSTALL_UP(j) x[upfence]=x[j]; y[upfence++]=y[j]; INIT(wedge) +#define INSTALL_DOWN(j) x[--downfence]=x[j]; y[downfence]=y[j]; INIT(wedge) +#define Max(a,b) ((a)>(b)?(a):(b)) +#define Min(a,b) ((a)<(b)?(a):(b)) + /* * An arc structure has a beginning angle and * an ending angle. It should be in a canonical @@ -57,8 +63,8 @@ static void intersect(a, begin, end) /* do the intersection ... */ else { - a->begin = MAX(begin, a->begin); - a->end = MIN(end, a->end); + a->begin = Max(begin, a->begin); + a->end = Min(end, a->end); } /* canonicalize the intersection if necessary */ @@ -90,10 +96,7 @@ int thin(x, y, n, delta, symmetric) /* non-symmetric thin goes from one end to the other */ if(!symmetric) { upfence = 0; - x[upfence]=x[0]; - y[upfence++]=y[0]; - wedge.begin = -PI; - wedge.end = PI; + INSTALL_UP(0); for(cur = 0, next = 1; next < n; next++) { dx = x[next] - x[cur]; dy = y[next] - y[cur]; @@ -102,10 +105,7 @@ int thin(x, y, n, delta, symmetric) theta = atan2(dy, dx); if(!inarc(wedge, theta)) { cur = --next; - x[upfence]=x[cur]; - y[upfence++]=y[cur]; - wedge.begin = -PI; - wedge.end = PI; + INSTALL_UP(cur); continue; } dist = hypot(dx, dy); @@ -114,19 +114,13 @@ int thin(x, y, n, delta, symmetric) intersect(&wedge, theta - alpha, theta + alpha); } } - x[upfence]=x[n-1]; - y[upfence++]=y[n-1]; - wedge.begin = -PI; - wedge.end = PI; + INSTALL_UP(n-1); return(upfence); } /* symmetric version: first thin from the beginning to the middle */ upfence = 0; mid = (n + 1) / 2; - x[upfence]=x[0]; - y[upfence++]=y[0]; - wedge.begin = -PI; - wedge.end = PI; + INSTALL_UP(0); for(cur = 0, next = 1; next < mid; next++) { dx = x[next] - x[cur]; dy = y[next] - y[cur]; @@ -135,10 +129,7 @@ int thin(x, y, n, delta, symmetric) theta = atan2(dy, dx); if(!inarc(wedge, theta)) { cur = --next; - x[upfence]=x[cur]; - y[upfence++]=y[cur]; - wedge.begin = -PI; - wedge.end = PI; + INSTALL_UP(cur); continue; } dist = hypot(dx, dy); @@ -147,18 +138,12 @@ int thin(x, y, n, delta, symmetric) intersect(&wedge, theta - alpha, theta + alpha); } } - x[upfence]=x[mid-1]; - y[upfence++]=y[mid-1]; - wedge.begin = -PI; - wedge.end = PI; + INSTALL_UP(mid-1); uptotal = upfence; /* now work from the end to the middle */ downfence = n; mid = n - mid; - x[--downfence]=x[n-1]; - y[downfence]=y[n-1]; - wedge.begin = -PI; - wedge.end = PI; + INSTALL_DOWN(n-1); for(cur = n-1, next = n-2; next >= mid; next--) { dx = x[next] - x[cur]; dy = y[next] - y[cur]; @@ -167,10 +152,7 @@ int thin(x, y, n, delta, symmetric) theta = atan2(dy, dx); if(!inarc(wedge, theta)) { cur = ++next; - x[--downfence]=x[cur]; - y[downfence]=y[cur]; - wedge.begin = -PI; - wedge.end = PI; + INSTALL_DOWN(cur); continue; } dist = hypot(dx, dy); @@ -179,10 +161,7 @@ int thin(x, y, n, delta, symmetric) intersect(&wedge, theta - alpha, theta + alpha); } } - x[--downfence]=x[mid]; - y[downfence]=y[mid]; - wedge.begin = -PI; - wedge.end = PI; + INSTALL_DOWN(mid); downtotal = n - downfence; /* for n odd, middle point is recorded twice, so fix that */ diff --git a/src/thin.c.orig b/src/thin.c.orig deleted file mode 100644 index be93ffa..0000000 --- a/src/thin.c.orig +++ /dev/null @@ -1,216 +0,0 @@ -#include "R.h" -#include "map.h" - -#define INIT(a) a.begin = -PI; a.end = PI -#define INSTALL_UP(j) x[upfence]=x[j]; y[upfence++]=y[j]; INIT(wedge) -#define INSTALL_DOWN(j) x[--downfence]=x[j]; y[downfence]=y[j]; INIT(wedge) -#define Max(a,b) ((a)>(b)?(a):(b)) -#define Min(a,b) ((a)<(b)?(a):(b)) - -/* - * An arc structure has a beginning angle and - * an ending angle. It should be in a canonical - * form such that the beginning angle is - * in [-PI,PI). This implies that the end - * angle is always greater than -PI, a fact - * which is assumed in the routines below which - * manipulate arcs. - */ -struct arc { - double begin; - double end; -}; - -/* - * Test whether theta lies in the arc a. - * Theta is expected to be in [-PI,PI). - */ -static int inarc(a, theta) - struct arc a; - double theta; -{ - if(a.begin <= theta && theta <= a.end) - return(1); - theta += PI2; - if(a.begin <= theta && theta <= a.end) - return(1); - return(0); -} - -/* - * Intersect the arc a with the arc defined by begin - * and end. The arc is assumed to be in canonical form - * but the arc defined by (begin,end) can be located - * anywhere. - */ -static void intersect(a, begin, end) - struct arc *a; - double begin, end; -{ - /* move (begin,end) until it has a chance to intersect a */ - while(end < a->begin) { - begin += PI2; - end += PI2; - } - while(begin > a->end) { - begin -= PI2; - end -= PI2; - } - - /* if no intersection ... */ - if(end < a->begin || begin > a->end) - a->begin = a->end = 0; - - /* do the intersection ... */ - else { - a->begin = Max(begin, a->begin); - a->end = Min(end, a->end); - } - - /* canonicalize the intersection if necessary */ - while(a->begin >= PI) { - a->begin -= PI; - a->end -= PI; - } -} - -/* - * Given an ordered list of n points in the plane, and - * a tolerance delta, find a subset of the points with - * the same ordering such that the linear spline passing - * through the new points passes within delta of each of - * the original points. - */ -static -int thin(x, y, n, delta, symmetric) - double x[], y[], delta; - int n, symmetric; -{ - int cur, next, mid, uptotal, downtotal, upfence, downfence, m; - double dist, theta, alpha, dx, dy; - struct arc wedge; - - if((symmetric && n <= 4) || (!symmetric && n <= 2) || delta <= 0) - return(n); - - /* non-symmetric thin goes from one end to the other */ - if(!symmetric) { - upfence = 0; - INSTALL_UP(0); - for(cur = 0, next = 1; next < n; next++) { - dx = x[next] - x[cur]; - dy = y[next] - y[cur]; - if(dx == 0 && dy == 0) - continue; - theta = atan2(dy, dx); - if(!inarc(wedge, theta)) { - cur = --next; - INSTALL_UP(cur); - continue; - } - dist = hypot(dx, dy); - if(dist > delta) { - alpha = asin(delta / dist); - intersect(&wedge, theta - alpha, theta + alpha); - } - } - INSTALL_UP(n-1); - return(upfence); - } - - /* symmetric version: first thin from the beginning to the middle */ - upfence = 0; mid = (n + 1) / 2; - INSTALL_UP(0); - for(cur = 0, next = 1; next < mid; next++) { - dx = x[next] - x[cur]; - dy = y[next] - y[cur]; - if(dx == 0 && dy == 0) - continue; - theta = atan2(dy, dx); - if(!inarc(wedge, theta)) { - cur = --next; - INSTALL_UP(cur); - continue; - } - dist = hypot(dx, dy); - if(dist > delta) { - alpha = asin(delta / dist); - intersect(&wedge, theta - alpha, theta + alpha); - } - } - INSTALL_UP(mid-1); - uptotal = upfence; - - /* now work from the end to the middle */ - downfence = n; mid = n - mid; - INSTALL_DOWN(n-1); - for(cur = n-1, next = n-2; next >= mid; next--) { - dx = x[next] - x[cur]; - dy = y[next] - y[cur]; - if(dx == 0 && dy == 0) - continue; - theta = atan2(dy, dx); - if(!inarc(wedge, theta)) { - cur = ++next; - INSTALL_DOWN(cur); - continue; - } - dist = hypot(dx, dy); - if(dist > delta) { - alpha = asin(delta / dist); - intersect(&wedge, theta - alpha, theta + alpha); - } - } - INSTALL_DOWN(mid); - downtotal = n - downfence; - - /* for n odd, middle point is recorded twice, so fix that */ - if(n % 2) { - downfence++; - downtotal--; - } - - /* now copy back upper half so that arrays are contiguous */ - for(m = 0; m < downtotal; m++) { - x[upfence] = x[downfence]; - y[upfence++] = y[downfence++]; - } - - return(uptotal + downtotal); -} - -void mapthin(x, y, n, delta, symmetric) - double *x, *y, *delta; - int *n, *symmetric; -{ - int start, end, m, from, to, wasna, isna, i; - - end = 0; - while(end < *n) { - start = end; - while(end < *n && !ISNA(x[end])) - end++; - m = thin(x+start, y+start, end-start, *delta, (int)*symmetric); - for(i = start+m; i < end; i++) { - x[i] = NA_REAL; - y[i] = NA_REAL; - } - while(end < *n && ISNA(x[end])) - end++; - } - wasna = 0; - for(from = to = 0; from < *n; from++) { - isna = ISNA(x[from]); - if(!isna) { - x[to] = x[from]; - y[to] = y[from]; - to++; - } else if(!wasna) { - x[to] = NA_REAL; - y[to] = NA_REAL; - to++; - } - wasna = isna; - } - *n = wasna ? to-1 : to; -}