├── .gitignore
├── LICENSE
├── README.md
├── book
├── pom.xml
└── src
│ └── main
│ └── latex
│ ├── common
│ └── images
│ │ ├── duty_calls.png
│ │ ├── map_projections.png
│ │ └── projections2.png
│ └── geotools-cookbook
│ ├── distance.tex
│ ├── filters.tex
│ ├── geotools-cookbook.tex
│ ├── input.tex
│ ├── introduction.tex
│ ├── output.tex
│ ├── postamble.tex
│ ├── preamble.tex
│ ├── preface.tex
│ ├── projections.tex
│ ├── refs.bib
│ └── styling.tex
├── data
├── TQ19.asc
├── coast_ln_polyline.avl
├── coast_ln_polyline.dbf
├── coast_ln_polyline.prj
├── coast_ln_polyline.qix
├── coast_ln_polyline.shp
├── coast_ln_polyline.shx
├── coastline.sld
├── ne_10m_admin_0_countries.README.html
├── ne_10m_admin_0_countries.dbf
├── ne_10m_admin_0_countries.prj
├── ne_10m_admin_0_countries.qix
├── ne_10m_admin_0_countries.shp
├── ne_10m_admin_0_countries.shx
├── states.dbf
├── states.prj
├── states.qix
├── states.shp
├── states.shx
├── states_conic.dbf
├── states_conic.fix
├── states_conic.prj
├── states_conic.shp
├── states_conic.shx
├── world.200412.3x21600x10800.jpg
└── world.200412.3x21600x10800.jpw
├── modules
├── distances
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── org
│ │ └── ianturton
│ │ └── cookbook
│ │ └── distances
│ │ ├── AutoProjection.java
│ │ ├── OrthodromicDistance.java
│ │ └── OrthodromicDistance2.java
├── filters
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── org
│ │ └── ianturton
│ │ └── cookbook
│ │ └── filters
│ │ ├── PointInPolygon.java
│ │ └── QueryGrid.java
├── input
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── org
│ │ └── ianturton
│ │ └── cookbook
│ │ └── input
│ │ └── SaveMapAsImage.java
├── output
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── org
│ │ └── ianturton
│ │ └── cookbook
│ │ └── output
│ │ ├── ExportGeometries.java
│ │ ├── MapWithGrid.java
│ │ ├── SaveMapAsImage.java
│ │ └── WriteShapefile.java
├── pom.xml
├── projections
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ └── java
│ │ └── org
│ │ └── ianturton
│ │ └── cookbook
│ │ └── projections
│ │ ├── QueryEPSG.java
│ │ ├── ReprojectShapeFile.java
│ │ └── Tissot.java
├── quickstart
│ ├── pom.xml
│ └── src
│ │ └── main
│ │ ├── java
│ │ └── org
│ │ │ └── geotools
│ │ │ └── tutorial
│ │ │ └── quickstart
│ │ │ ├── Quickstart.java
│ │ │ ├── QuickstartCache.java
│ │ │ └── QuickstartNotes.java
│ │ └── main
│ │ ├── java
│ │ └── org
│ │ │ └── geotools
│ │ │ ├── api
│ │ │ ├── APIExamples.java
│ │ │ ├── DataStoreExamples.java
│ │ │ └── validation
│ │ │ │ └── ValidationExamples.java
│ │ │ ├── brewer
│ │ │ └── BrewerExamples.java
│ │ │ ├── coverage
│ │ │ └── CoverageExamples.java
│ │ │ ├── cql
│ │ │ ├── CQLExamples.java
│ │ │ ├── DataExamples.java
│ │ │ ├── ECQLExamples.java
│ │ │ └── Utility.java
│ │ │ ├── data
│ │ │ ├── DataExamples.java
│ │ │ ├── SimpleFeatureStoreExamples.java
│ │ │ └── property
│ │ │ │ ├── PropertyAttributeReader.java
│ │ │ │ ├── PropertyDataStore.java
│ │ │ │ ├── PropertyDataStoreFactory.java
│ │ │ │ ├── PropertyExamples.java
│ │ │ │ └── PropertyFeatureReader.java
│ │ │ ├── geometry
│ │ │ └── GeometryExamples.java
│ │ │ ├── graph
│ │ │ └── GraphExamples.java
│ │ │ ├── grid
│ │ │ ├── GridExamples.java
│ │ │ └── IntersectionBuilder.java
│ │ │ ├── jdbc
│ │ │ └── JDBCExamples.java
│ │ │ ├── jts
│ │ │ ├── JTSExamples.java
│ │ │ └── SnapToLine.java
│ │ │ ├── main
│ │ │ ├── FilterExamples.java
│ │ │ ├── JoinExample.java
│ │ │ └── MainExamples.java
│ │ │ ├── metadata
│ │ │ ├── Example.java
│ │ │ └── MetadataExamples.java
│ │ │ ├── opengis
│ │ │ ├── FeatureExamples.java
│ │ │ ├── FilterExamples.java
│ │ │ └── StyleExamples.java
│ │ │ ├── po
│ │ │ ├── Items.java
│ │ │ ├── ObjectFactory.java
│ │ │ ├── PurchaseOrderType.java
│ │ │ ├── USAddress.java
│ │ │ ├── bindings
│ │ │ │ ├── ItemsBinding.java
│ │ │ │ ├── Items_itemBinding.java
│ │ │ │ ├── PO.java
│ │ │ │ ├── POConfiguration.java
│ │ │ │ ├── PurchaseOrderTypeBinding.java
│ │ │ │ ├── SKUBinding.java
│ │ │ │ └── USAddressBinding.java
│ │ │ └── package-info.java
│ │ │ ├── process
│ │ │ └── FeatureProcessExamples.java
│ │ │ ├── referencing
│ │ │ └── ReferencingExamples.java
│ │ │ ├── render
│ │ │ ├── GenerateSVG.java
│ │ │ ├── SplatMarkFactory.java
│ │ │ ├── StyleConverter.java
│ │ │ └── StyleExamples.java
│ │ │ ├── swing
│ │ │ ├── JExampleWizard.java
│ │ │ └── JMapPaneExamples.java
│ │ │ ├── tutorial
│ │ │ ├── crs
│ │ │ │ └── CRSLab.java
│ │ │ ├── datastore
│ │ │ │ ├── CSVDataStore.java
│ │ │ │ ├── CSVFeatureReader.java
│ │ │ │ └── CSVFeatureSource.java
│ │ │ ├── feature
│ │ │ │ └── Csv2Shape.java
│ │ │ ├── filter
│ │ │ │ └── QueryLab.java
│ │ │ ├── function
│ │ │ │ ├── AbstractFunction.java
│ │ │ │ ├── ExampleFinder.java
│ │ │ │ ├── ExampleFunctionFactory.java
│ │ │ │ ├── ExampleFunctionFactory2.java
│ │ │ │ └── SnapFunction.java
│ │ │ ├── graph
│ │ │ │ └── Tiger.java
│ │ │ ├── package-info.java
│ │ │ ├── process
│ │ │ │ ├── BufferFactory.java
│ │ │ │ ├── BufferFeatureCollectionFactory.java
│ │ │ │ ├── BufferFeatureCollectionProcess.java
│ │ │ │ ├── BufferProcess.java
│ │ │ │ ├── ProcessExample.java
│ │ │ │ └── ProcessTutorial.java
│ │ │ ├── quickstart
│ │ │ │ ├── Quickstart.java
│ │ │ │ ├── QuickstartCache.java
│ │ │ │ └── QuickstartNotes.java
│ │ │ ├── raster
│ │ │ │ └── ImageLab.java
│ │ │ ├── style
│ │ │ │ ├── SelectionLab.java
│ │ │ │ └── StyleLab.java
│ │ │ └── wms
│ │ │ │ └── WMSLab.java
│ │ │ └── xml
│ │ │ ├── FilterXMLExamples.java
│ │ │ ├── GML2Schema.java
│ │ │ ├── GMLExamples.java
│ │ │ ├── GMLParsing.java
│ │ │ ├── TestSchema.java
│ │ │ └── YourCode.java
│ │ └── resources
│ │ ├── META-INF
│ │ └── services
│ │ │ └── org.geotools.process.ProcessFactory
│ │ └── org
│ │ └── geotools
│ │ ├── cql
│ │ └── usa-geometry.wkt
│ │ ├── grid
│ │ ├── oz.dbf
│ │ ├── oz.fix
│ │ ├── oz.prj
│ │ ├── oz.qix
│ │ ├── oz.shp
│ │ └── oz.shx
│ │ └── xml
│ │ ├── states.xml
│ │ └── states.xsd
└── styling
│ ├── pom.xml
│ └── src
│ └── main
│ └── java
│ └── org
│ └── ianturton
│ └── cookbook
│ └── styling
│ ├── FontManagement.java
│ └── TwoAttributes.java
└── pom.xml
/.gitignore:
--------------------------------------------------------------------------------
1 | *.class
2 | .gitignore
3 |
4 | # Mobile Tools for Java (J2ME)
5 | .mtj.tmp/
6 |
7 | # Package Files #
8 | *.jar
9 | *.war
10 | *.ear
11 |
12 | #latex stuff
13 |
14 | *.aux
15 | *.toc
16 | *.log
17 | *.lol
18 | *.out
19 |
20 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
21 | hs_err_pid*
22 |
23 | #eclipse files
24 | .project
25 | .classpath
26 | .settings/*
27 | *.prefs
28 | target/*
29 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | geotools-cookbook
2 | =================
3 |
4 | This is a draft of the text and code for a cookbook that aims to introduce new users to the tricks and tips that make using GeoTools more fun.
5 |
--------------------------------------------------------------------------------
/book/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | org.ianturton
8 | cookbook
9 | 1.0
10 |
11 | com.ianturton.cookbook
12 | book
13 | 1.0-SNAPSHOT
14 |
15 |
16 | codehaus
17 | Maven Codehaus repository
18 | http://repository.codehaus.org/
19 |
20 |
21 | codehaus-snapshots
22 | Maven Codehaus snapshot repository
23 | http://snapshots.repository.codehaus.org/
24 |
25 |
26 |
27 |
28 | maven-latex-plugin-repo
29 | http://akquinet.github.com/maven-latex-plugin/maven2/
30 |
31 | true
32 |
33 |
34 |
35 |
36 |
37 |
38 | ${basedir}/src/main/latex/geotools-cookbook
39 | true
40 |
41 | **/*.tex
42 | **/images/*
43 |
44 |
45 |
46 | ${basedir}/src/main/latex/common
47 |
48 | **/images/*
49 |
50 |
51 |
52 |
53 |
54 |
55 | de.akquinet.maven
56 | maven-latex-plugin
57 | 1.1
58 |
59 |
60 | compile
61 |
62 | latex
63 |
64 |
65 |
66 |
67 |
68 |
69 |
71 | ${basedir}/target/classes
72 |
74 | .
75 |
77 | m2latex
78 |
79 | true
80 |
81 |
82 |
83 | pdflatex
84 |
85 | bibtex
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 | org.eclipse.m2e
95 | lifecycle-mapping
96 | 1.0.0
97 |
98 |
99 |
100 |
101 |
102 |
103 | de.akquinet.maven
104 |
105 |
106 | maven-latex-plugin
107 |
108 |
109 | [1.1,)
110 |
111 |
112 | latex
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
--------------------------------------------------------------------------------
/book/src/main/latex/common/images/duty_calls.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ianturton/geotools-cookbook/a2364bcf41007dabce93d34eda7c8e8e61015222/book/src/main/latex/common/images/duty_calls.png
--------------------------------------------------------------------------------
/book/src/main/latex/common/images/map_projections.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ianturton/geotools-cookbook/a2364bcf41007dabce93d34eda7c8e8e61015222/book/src/main/latex/common/images/map_projections.png
--------------------------------------------------------------------------------
/book/src/main/latex/common/images/projections2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ianturton/geotools-cookbook/a2364bcf41007dabce93d34eda7c8e8e61015222/book/src/main/latex/common/images/projections2.png
--------------------------------------------------------------------------------
/book/src/main/latex/geotools-cookbook/distance.tex:
--------------------------------------------------------------------------------
1 | \chapter{Distances and GeoFencing}
2 |
3 |
4 |
5 | \lstinputlisting[firstline=21,firstnumber=21,caption=How to calculate the distance between two points.]
6 | {distances/src/main/java/org/ianturton/cookbook/distances/OrthodromicDistance.java}
7 | \label{distance1}
8 |
--------------------------------------------------------------------------------
/book/src/main/latex/geotools-cookbook/filters.tex:
--------------------------------------------------------------------------------
1 | \chapter{Querying, Filtering and Sorting: finding what you need}\label{filters}
2 | \section{Creating and running a query}
3 | \section{Filters}
4 | \subsection{OGC Filters}
5 | \subsection{CQL Filters}
6 | \section{Sorting your results}
--------------------------------------------------------------------------------
/book/src/main/latex/geotools-cookbook/geotools-cookbook.tex:
--------------------------------------------------------------------------------
1 | \RequirePackage[l2tabu, orthodox]{nag}
2 | %\documentclass[a4paper]{tufte-book}
3 | \documentclass{scrbook}
4 | % leave this last
5 | \usepackage[bookmarksdepth=subsection,hidelinks]{hyperref}
6 | \usepackage{scrhack}
7 | \usepackage{todonotes}
8 | %\usepackage[printonlyused,withpage]{acronym}
9 | \usepackage{acronym}
10 | \usepackage{listings}
11 | \usepackage{graphicx}
12 | \usepackage{siunitx}
13 | \usepackage{caption}
14 | \usepackage{xspace}
15 | \usepackage{microtype}
16 | \usepackage{cleveref}
17 | \usepackage[comma,authoryear]{natbib}
18 | \usepackage{spverbatim}
19 | \usepackage{ccicons}
20 |
21 | % fix the kerning in GeoTools to look nicer (to me)
22 | \newcommand{\GeoTools}{Geo\kern -.15em T\kern -.15em ools\xspace}
23 | \DeclareRobustCommand\Hazard[1][red]{\makebox[0pt][r]{\color{#1}\huge\Biohazard\hspace{2em}}}
24 | \title{\GeoTools Cookbook}
25 | \author{Ian Turton}
26 |
27 | % define how the listings will look
28 | \lstset{
29 | basicstyle=\footnotesize\ttfamily,numbers=left, numberstyle=\tiny, numbersep=5pt,
30 | frame=single,
31 | breaklines=true,
32 | postbreak=\raisebox{0ex}[0ex][0ex]{\ensuremath{\color{red}\hookrightarrow\space}}
33 | }
34 | \lstset{tabsize=2}
35 | \lstloadlanguages{java}
36 |
37 | %and finally start the book!
38 |
39 | \begin{document}
40 | \maketitle
41 | \tableofcontents
42 | \lstlistoflistings
43 | \clearpage
44 |
45 | \include{preface}
46 | \include{introduction}
47 | \include{input}
48 | \include{output}
49 | \include{filters}
50 | \include{styling}
51 | \include{projections}
52 | \include{distance}
53 | \todo{add the rest of the chapters as includes}
54 | \chapter{Going Further}
55 | \bibliographystyle{plainnat}
56 | \bibliography{refs}
57 | % this contains the acronyms - which for some reason doesn't work at the front.
58 | \include{postamble}
59 | \todo{remove this list when finished}
60 | \listoftodos
61 | \end{document}
62 |
--------------------------------------------------------------------------------
/book/src/main/latex/geotools-cookbook/input.tex:
--------------------------------------------------------------------------------
1 | \chapter{Input, getting the data in to \GeoTools}\label{input}
2 | \section{Vector Datasets}\label{vector}
3 | \section{Raster Datasets}\label{raster}
--------------------------------------------------------------------------------
/book/src/main/latex/geotools-cookbook/introduction.tex:
--------------------------------------------------------------------------------
1 | \chapter{Introduction}\label{introduction}
2 |
3 | \section{Getting Started}
4 | I'm going to make the assumption that as a Java developer who already have a favourite set of development tools and are fairly happy in how to use them.
5 |
6 | \subsection{Maven}
7 | One of the things that often worries or confuses new users of the \GeoTools library is it's use of the Maven build system. So people will pop up on the mailing list asking why they have a missing method when trying to compile one of the tutorial programs, this is almost always because they have not installed and used maven.
8 | To get anywhere with \GeoTools you will need to have \href{http://maven.apache.org/}{Apache Maven} installed on your machine. Maven is an automated build management tool, once upon a time programmers used to use \texttt{make} to control how a program was built, it ``knew'' how to turn files ending in \texttt{.c} or \texttt{.f} into \texttt{.o} files and with some hints from the developer how to put those files together into an executable file. When your program consisted of 10's of files this was fine but things soon broke down. The \texttt{C} and \texttt{C++} communities started to extend this system with \texttt{autoconfig} and \texttt{cmake} to automatically build a \texttt{make} file for you. The Java community (with it's love of XML) went to \href{http://ant.apache.org/}{\texttt{ant}} which was more aware of how Java programs went together. But over time \texttt{ant} build files became hard to manage, eventually maven was born. It favours convention over configuration, or more plainly if you put your files in the right place maven will find and build them. Maven also simplifies dependency management, you simply specify the the jar that you need to add to make your program work and maven will go off, find and download not just that jar file but also the jars that it depends on. We will return to this later in this chapter but for now make sure Maven is installed on your machine. If you use Eclipse or Netbeans as your \ac{IDE} then maven is already built in, but you might want to download the standalone version anyway.
9 |
10 | \section{Hello World}
11 |
12 | There is an \href{http://en.wikipedia.org/wiki/\%22Hello,_world!\%22_program}{unwritten law} that any programming book must include a Hello World program. This is because it is normally easy to print out a simple string which means the beginning programmer can concentrate on the form of the program rather than it's actual algorithm. Since this is a book for geographers/programmers we will start with a program that displays a map of the world (rather than a string).
13 |
14 | A slightly trimmed version of the code you will need is shown in \cref{HelloWorld}, the full program is about 50 lines long. \todo{Add note on where to download code samples} \Cref{pom} shows the maven pom file you will need compile it, you'll notice that it is about the same length as the program itself\footnote{So may be there is some truth to what the maven haters say}. So to display a map we first need to compile the program \verb!mvn compile! -- you'll see lots of messages scroll across the screen telling you about the jar files that maven has fetched for you. If that all goes well then you can use \verb!mvn exec:java! to run the program.
15 |
16 | \lstinputlisting[firstline=29,firstnumber=29,lastline=54,caption={Hello World GIS style},label=HelloWorld]{quickstart/src/main/java/org/geotools/tutorial/quickstart/Quickstart.java}
17 |
18 | \lstinputlisting[caption={Maven Pom file}, label=pom, language=xml]{quickstart/pom.xml}
19 |
20 |
--------------------------------------------------------------------------------
/book/src/main/latex/geotools-cookbook/output.tex:
--------------------------------------------------------------------------------
1 | \chapter{Output}
2 | \todo{think of a better title}
3 |
4 | \section{Introduction}
5 | Once you have your data set up the way you would like you will want
6 | to export it in some sort of form that allows you to use it.
7 |
8 | \section{Working with Geometries}\label{geoms}
9 | \todo{decide where this should go}
10 | Within \GeoTools geometries are represented by \ac{JTS} Geometries that contain the actual positions as Coordinates.
11 | Sometimes when exporting geometries you would like to produce a plain text string that represents the geometry, if for no other reason than it's easier to see what is happening than starting up a debugger.
12 | This sort of interoperability issue comes up often enough that there is a standard way of doing it (well two in fact). The most common format is \ac{WKT}.
13 |
14 | \lstinputlisting[firstline=38,firstnumber=38,lastline=40,label=wkt,caption={Exporting WKT from a geometry}]{output/src/main/java/org/ianturton/cookbook/output/ExportGeometries.java}
15 |
16 | \Cref{wkt} shows just how simple this process is. This will produce output like \cref{wktoutput}. WKT is kept deliberately simple so that writing a program that can read it in or write it out is easy. The standard was originally written by the \ac{OGC} as part of Simple Feature specification, it is now defined in the ISO 13249 ``Information technology -- Database languages -- SQL multimedia and application packages -- Part 3: Spatial'' standard.
17 |
18 | \begin{figure}[h]
19 | \begin{spverbatim}
20 | POINT (10.1 22.2)
21 | LINESTRING (1 1, 2 3, 4.4 5.2)
22 | POLYGON ((1 1, 2 3, 4.4 5.2, 1 1))
23 | MULTIPOLYGON (((1 1, 2 3, 4.4 5.2, 1 1)),
24 | ((10 10, 20 30, 40.4 50.2, 10 10)))
25 | \end{spverbatim}
26 | \caption{Some examples of WKT}\label{wktoutput}
27 | \end{figure}
28 |
29 | One important point to notice is that \spverb!POLYGON! has two parenthesis at the start and end, this allows you to specify holes in your polygon (think islands in a lake) which are represented like \spverb!POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10),(20 30, 35 35, 30 20, 20 30))!.
30 |
31 | \section{Creating an Image of the Map}
32 | Assuming that you have created a map that you like with the correct styling and area of interest
33 | set then you might want to produce a picture of it. \Cref{save} shows how to do this.
34 |
35 | \lstinputlisting[firstline=27,firstnumber=27,label=save,caption=Save a picture of the map.]{output/src/main/java/org/ianturton/cookbook/output/SaveMapAsImage.java}
36 |
37 | \section{Create a New Shapefile}
38 |
39 | \lstinputlisting[firstline=40,firstnumber=40,label=shapefile,caption=Save a shapefile.]{output/src/main/java/org/ianturton/cookbook/output/WriteShapefile.java}
40 |
41 |
--------------------------------------------------------------------------------
/book/src/main/latex/geotools-cookbook/postamble.tex:
--------------------------------------------------------------------------------
1 | \cleardoublepage
2 | \chapter*{Acronyms}
3 | \begin{acronym}[XXXXX]
4 | \acro{OGC}{Open Geospatial Consortium}
5 | \acro{JTS}{Java Topology Suite}
6 | \acro{WKT}{Well Known Text}
7 | \acro{WKB}{Well Known Binary}
8 | \acro{ISO}{International Standards Organization}
9 | \acro{CCG}{Centre for Computational Geography}
10 | \acro{GIS}{Geographic Information System}
11 | \acro{TOPP}{The Open Planning Project}
12 | \acro{IDE}{Integrated Development Environment}
13 | \end{acronym}
14 |
--------------------------------------------------------------------------------
/book/src/main/latex/geotools-cookbook/preamble.tex:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ianturton/geotools-cookbook/a2364bcf41007dabce93d34eda7c8e8e61015222/book/src/main/latex/geotools-cookbook/preamble.tex
--------------------------------------------------------------------------------
/book/src/main/latex/geotools-cookbook/preface.tex:
--------------------------------------------------------------------------------
1 | \chapter{Preface}
2 | \section{About this book}
3 | This book is a gentle introduction to the \GeoTools library. It is aimed at developers who have a geographic problem that they want to solve in Java.
4 |
5 | \section{About the author}
6 | I'm a programmer and while waiting for my code to compile I hang out on the \href{http://gis.stackexchange.com/}{GIS StackExchange site} answering questions as \texttt{iant}. Over the past 4 years I've answered more than 600 questions, adding this experience to the issues I helped students with when I worked at Leeds University and Pennsylvania State University, I think I've got a pretty good idea of where people go wrong when starting out with geography and geographic programs. The aim of this book is to distil some of my knowledge in to a form I can point people to, which should save me some typing in the future.
7 |
8 | However as XKCD points out in \cref{xkcd-duty} it's unlikely to solve all my problems.
9 |
10 |
11 | \begin{figure}[htbp]
12 | {\centering
13 | \includegraphics{images/duty_calls}
14 | \caption{Why we need this book?\\ \ccbync~\href{http://xkcd.com/386/}{XKCD}}
15 | \label{xkcd-duty}
16 | }
17 | \end{figure}
18 |
19 | \section{Who is this book for?}
20 | You are a Java developer who has written a number of complex programs already, you know how to set up your development environment whether it is an \ac{IDE} or a command line and text editor. You are happy using Maven to manage your code (or at least willing to learn) and you have a interest in geographic problems (or your boss has). However, you are smart and you don't want to have to write a whole geographic library for yourself from scratch. You have no time or energy to look up the Shapefile white paper \citep{ESRI1997} to see how to read your data in, or work out the projection needed to make the map equal area.
21 |
22 | So to make your life easier you've picked an existing library but now you have to learn how that works. This book will help you solve common problems using the \GeoTools library.
23 |
24 | The joy of Java programming is that it doesn't matter if you use a Linux machine, a windows box or even a Mac. But beware many parts of the \GeoTools library depend on the AWT and the Java Service Provider mechanism neither of which work on Android devices at the time of writing, so if you want to write Android applications you will need to find another library. That's not to say you can't take some of the code and techniques shown here on Android just that there is a fairly good chance that it will not work as is.
25 |
26 | \section{A brief history of \GeoTools}
27 | Once upon a time, when I was a newish (and keen) post--doctoral researcher in the \ac{CCG} at the University of Leeds there was a younger (and keener) Master's student call James Macgill who wanted to investigate swarms of agents moving around a map. The current state of the art \ac{GIS} system was unable to do more than draw a simple map. The ``obvious'' solution was to write our own \ac{GIS} system and so \GeoTools was born. Version 1 of the library was really intended for internal use only but news of leaked out and people (like \ac{TOPP} started to use it). Overtime a user community developed, and then they started wanting bug fixes and new features! It was terrible, as by now both of us had other jobs to do and very little spare time for \GeoTools. At the same time it was becoming apparent that there were some design choices that would make extending the library any further difficult, so we took the only sensible course of action and abandoned the project. We then replaced \GeoTools--1 with \GeoTools--2, which was redesigned to incorporate all (or at least some of) the lessons we had learned in \GeoTools--1.
28 |
29 | \GeoTools--2 was built on a generic feature definition, to start with it only supported \ac{OGC} Simple Features, but later when users needed complex features it was (relatively) easy to add support for them. We also switched from using Ant to Maven to manage the build and started to produce modular jar files to allow users to pick and choose the parts they wanted to use. We also recruited a bunch of new developers from \ac{TOPP} and Refractions Research who were building the GeoServer WMS Server and the UDig editor respectively.
30 |
31 | After a while it became clear that \GeoTools--3 was never going to arrive (or it is a long way in the future) so the version of the \GeoTools library moved from 2.7.x to 8.0. This book has been developed against version ${geotools.version} of the library.
32 |
--------------------------------------------------------------------------------
/book/src/main/latex/geotools-cookbook/projections.tex:
--------------------------------------------------------------------------------
1 | \chapter{Projections}
2 | \section{Introduction}
3 | Why we need to worry about projections? I'm going to let you in on a geographic secret ``the world is round'' -- sadly most of the maps we draw are \textbf{flat}. This leaves us with a problem, as anyone who has ever tried to gift wrap a globe knows, it's hard to make a curved surface and a flat sheet match up.
4 |
5 | As the ever helpful XKCD points out in \cref{xkcd-projections} there are a lot of projections.
6 |
7 | \todo{make this image narrower}
8 | \begin{figure}[htbp]
9 | {%
10 | \setlength{\fboxsep}{0pt}%
11 | \setlength{\fboxrule}{1pt}%
12 | \fbox{\includegraphics[width=\textwidth]{images/projections2}}%
13 | }%
14 |
15 | \caption{A quick introduction to projections\\ \ccbync~\href{http://xkcd.com/977/}{XKCD}}
16 | \label{xkcd-projections}
17 | \end{figure}
18 |
19 | Before you go too deep into the world of projections you should download and (at least) skim \cite{snyder}. This will give you access to all the helpful maths that \GeoTools encodes for you (or if you are unlucky that you will need to add a new projection to the library).
20 |
21 | \section{How to reproject features in \GeoTools}
22 | \section{How to choose a ``good'' projection}
--------------------------------------------------------------------------------
/book/src/main/latex/geotools-cookbook/refs.bib:
--------------------------------------------------------------------------------
1 | % This file was created with JabRef 2.10.
2 | % Encoding: Cp1252
3 |
4 |
5 | @Book{Peterson2012,
6 | Title = {Cartographer's toolkit},
7 | Author = {Gretchen N. Peterson},
8 | Publisher = {PetersonGIS},
9 | Year = {2012},
10 |
11 | Owner = {ian.turton},
12 | Timestamp = {2014.11.18}
13 | }
14 |
15 | @TechReport{snyder,
16 | Title = {Map Projections -- A Working Manual},
17 | Author = {John P. Snyder},
18 | Institution = {U.S. Geological Survey},
19 | Year = {1987},
20 | Number = {1395},
21 | Type = {Professional Paper},
22 |
23 | Owner = {ian.turton},
24 | Timestamp = {2014.11.17},
25 | Url = {http://pubs.usgs.gov/pp/1395/report.pdf}
26 | }
27 |
28 |
--------------------------------------------------------------------------------
/book/src/main/latex/geotools-cookbook/styling.tex:
--------------------------------------------------------------------------------
1 | \chapter{Styling: How to make a pretty map.}\label{styling}
2 | \section{Introduction}
3 | Try to read \cite{Peterson2012} to see how cartography is really done.
4 | \section{Colouring Features}
5 | \section{Line Styles}
6 | \section{Fonts}
7 |
--------------------------------------------------------------------------------
/data/coast_ln_polyline.avl:
--------------------------------------------------------------------------------
1 | /3.2
2 | (ODB.1
3 | FirstRootClassName: "Legend"
4 | Roots: 2
5 | Version: 32
6 | )
7 |
8 | (Legend.2
9 | SymType: 0x01
10 | LegType: 0x01
11 | ClassType: 0x03
12 | Symbols: 3
13 | Class: 6
14 | StdDevs: 1.00000000000000
15 | NullSym: 7
16 | NullValues: 9
17 | StatValues: 10
18 | Precision: -3
19 | )
20 |
21 | (SymList.3
22 | Child: 4
23 | )
24 |
25 | (BLnSym.4
26 | Color: 5
27 | Width: 1.00000000000000
28 | Pattern: 0.00000000000000
29 | Pattern: 0.00000000000000
30 | Pattern: 0.00000000000000
31 | Pattern: 0.00000000000000
32 | Pattern: 0.00000000000000
33 | Pattern: 0.00000000000000
34 | Pattern: 0.00000000000000
35 | Pattern: 0.00000000000000
36 | Pattern: 0.00000000000000
37 | Pattern: 0.00000000000000
38 | Pattern: 0.00000000000000
39 | Pattern: 0.00000000000000
40 | Pattern: 0.00000000000000
41 | Pattern: 0.00000000000000
42 | Pattern: 0.00000000000000
43 | Pattern: 0.00000000000000
44 | )
45 |
46 | (TClr.5
47 | Red: 0xfe
48 | Green: 0xdb57
49 | Blue: 0xff00
50 | )
51 |
52 | (LClass.6
53 | IsText: 1
54 | Precision: -3
55 | )
56 |
57 | (BLnSym.7
58 | Color: 8
59 | Width: 0.10000000000000
60 | Pattern: 0.00000000000000
61 | Pattern: 0.00000000000000
62 | Pattern: 0.00000000000000
63 | Pattern: 0.00000000000000
64 | Pattern: 0.00000000000000
65 | Pattern: 0.00000000000000
66 | Pattern: 0.00000000000000
67 | Pattern: 0.00000000000000
68 | Pattern: 0.00000000000000
69 | Pattern: 0.00000000000000
70 | Pattern: 0.00000000000000
71 | Pattern: 0.00000000000000
72 | Pattern: 0.00000000000000
73 | Pattern: 0.00000000000000
74 | Pattern: 0.00000000000000
75 | Pattern: 0.00000000000000
76 | )
77 |
78 | (TClr.8
79 | Name: "Transparent"
80 | )
81 |
82 | (NameDict.9
83 | )
84 |
85 | (NameDict.10
86 | )
87 |
88 |
--------------------------------------------------------------------------------
/data/coast_ln_polyline.dbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ianturton/geotools-cookbook/a2364bcf41007dabce93d34eda7c8e8e61015222/data/coast_ln_polyline.dbf
--------------------------------------------------------------------------------
/data/coast_ln_polyline.prj:
--------------------------------------------------------------------------------
1 | PROJCS["British_National_Grid",GEOGCS["GCS_OSGB_1936",DATUM["D_OSGB_1936",SPHEROID["Airy_1830",6377563.396,299.3249646]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",400000.0],PARAMETER["False_Northing",-100000.0],PARAMETER["Central_Meridian",-2.0],PARAMETER["Scale_Factor",0.9996012717],PARAMETER["Latitude_Of_Origin",49.0],UNIT["Meter",1.0]]
--------------------------------------------------------------------------------
/data/coast_ln_polyline.qix:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ianturton/geotools-cookbook/a2364bcf41007dabce93d34eda7c8e8e61015222/data/coast_ln_polyline.qix
--------------------------------------------------------------------------------
/data/coast_ln_polyline.shp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ianturton/geotools-cookbook/a2364bcf41007dabce93d34eda7c8e8e61015222/data/coast_ln_polyline.shp
--------------------------------------------------------------------------------
/data/coast_ln_polyline.shx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ianturton/geotools-cookbook/a2364bcf41007dabce93d34eda7c8e8e61015222/data/coast_ln_polyline.shx
--------------------------------------------------------------------------------
/data/coastline.sld:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | Meridian™ 2
7 |
8 | Coastline
9 | Meridian™ 2. Ordnance Survey. © Crown copyright and database rights 2013.
10 |
11 |
12 |
13 |
14 |
15 | Coastline - 1:23,607 To 1:94,482
16 |
17 |
18 | CODE
19 | 6200
20 |
21 |
22 | 23607
23 | 94482
24 |
25 |
26 | #5DC6DE
27 | 0.75
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/data/ne_10m_admin_0_countries.dbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ianturton/geotools-cookbook/a2364bcf41007dabce93d34eda7c8e8e61015222/data/ne_10m_admin_0_countries.dbf
--------------------------------------------------------------------------------
/data/ne_10m_admin_0_countries.prj:
--------------------------------------------------------------------------------
1 | GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]]
--------------------------------------------------------------------------------
/data/ne_10m_admin_0_countries.qix:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ianturton/geotools-cookbook/a2364bcf41007dabce93d34eda7c8e8e61015222/data/ne_10m_admin_0_countries.qix
--------------------------------------------------------------------------------
/data/ne_10m_admin_0_countries.shp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ianturton/geotools-cookbook/a2364bcf41007dabce93d34eda7c8e8e61015222/data/ne_10m_admin_0_countries.shp
--------------------------------------------------------------------------------
/data/ne_10m_admin_0_countries.shx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ianturton/geotools-cookbook/a2364bcf41007dabce93d34eda7c8e8e61015222/data/ne_10m_admin_0_countries.shx
--------------------------------------------------------------------------------
/data/states.dbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ianturton/geotools-cookbook/a2364bcf41007dabce93d34eda7c8e8e61015222/data/states.dbf
--------------------------------------------------------------------------------
/data/states.prj:
--------------------------------------------------------------------------------
1 | GEOGCS["GCS_WGS_1984",DATUM["WGS_1984",SPHEROID["WGS_1984",6378137,298.257223563]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]]
2 |
--------------------------------------------------------------------------------
/data/states.qix:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ianturton/geotools-cookbook/a2364bcf41007dabce93d34eda7c8e8e61015222/data/states.qix
--------------------------------------------------------------------------------
/data/states.shp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ianturton/geotools-cookbook/a2364bcf41007dabce93d34eda7c8e8e61015222/data/states.shp
--------------------------------------------------------------------------------
/data/states.shx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ianturton/geotools-cookbook/a2364bcf41007dabce93d34eda7c8e8e61015222/data/states.shx
--------------------------------------------------------------------------------
/data/states_conic.dbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ianturton/geotools-cookbook/a2364bcf41007dabce93d34eda7c8e8e61015222/data/states_conic.dbf
--------------------------------------------------------------------------------
/data/states_conic.fix:
--------------------------------------------------------------------------------
1 | 1
2 |
3 |
! " ! # " $ # % $ &