Java Programming for Spatial Sciences
eBook - ePub

Java Programming for Spatial Sciences

  1. 336 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

Java Programming for Spatial Sciences

About this book

The Java programming language has been one of the most exciting internet-friendly technologies to emerge in the last decade. Java Programming for Spatial Sciences introduces the subject to those who wish to use computers to handle information with a geographical element.The book introduces object-oriented modeling including key concepts suc

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription.
At the moment all of our mobile-responsive ePub books are available to download via the app. Most of our PDFs are also available to download and we're working on making the final remaining ones downloadable now. Learn more here.
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes! You can use the Perlego app on both iOS or Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Yes, you can access Java Programming for Spatial Sciences by Jo Wood in PDF and/or ePUB format, as well as other popular books in Computer Science & Programming Languages. We have over one million books available in our catalogue for you to explore.

Information

CHAPTER ONE
Introduction

1.1 WELCOME

This book is written for those who have an interest in getting computers to perform tasks that solve particular problems. Of course, most computer use is intended to perform such tasks, whether sending e-mail or using a Geographical Information System (GIS) to print a paper map. What we hope to develop in the pages of this book is the ability to express a problem in a way that a computer understands, allowing us more precision and control over what computers do for us.
The Java programming language provides us with a mechanism for both organising our thoughts and communicating with computers. So, the general aims of this book are twofold:
  1. To develop a way of thinking in order to be able to take a problem and express its solution using object-oriented modelling.
  2. To build-up knowledge of the Java language in order to be able to solve the types of problems faced when dealing with spatial information.

1.1.1 The Intended Audience

This book is written for novice programmers as well as those with some experience of programming in other languages. It has arisen from the author’s 10-year experience of teaching programming to geographers and information scientists, most of whom had no previous programming experience. While no experience of handling spatial information is required, it is assumed that readers have some motivation for doing so. So, in no particular order, here are six readers who might benefit from reading this book.
Sandra is a postgraduate student studying for a degree in Geographic Information Science (GI Science). She has used a GIS for a few months but wishes to have a more detailed and critical understanding of how the computer software handles GIS data.
Orlando is an archaeologist who has spent the last 3 years collecting data on artefact locations in Southern Spain. He has never programmed before but would like to place his data ‘on the web’ and allow others to perform spatial analysis on them.
Sheila is a geomorphologist who learnt to program in Fortran 20 years ago and wishes to update her programming skills, which she hopes to be able to apply to her ongoing research on landscape change.
Jay is a social scientist who is used to using statistics packages to analyse her data on social exclusion. She suspects that there are spatial patterns to her data but she finds her statistics software rather limited in terms of spatial mapping and analysis.
Leo works for a company providing bespoke paper maps for clients. He wishes to develop a simple software application that allows clients to browse and purchase digital copies of his maps.
Brian is interested in mobile communication technologies and wishes to explore how they might be used to provide location-based services to handheld devices. He would like to know more about how Java can be used in this context.

1.1.2 How to Use this Book

If you have never programmed in any language before, the best way of using this book is to start at the beginning and work through the chapters in sequence. Each chapter builds upon the skills and knowledge of the previous ones. For those who wish to concentrate on particular aspects of Java programming, there are also a number of ‘threads’ which run through the book.

Graphical techniques and user interface design. Sections 3.4, 4.6, 4,7, 6.4, 8.3, 10.2, 10.4
Spatial Data Modelling. Sections 4.5, 5.5, 7.1, 7.2, 8.3, 9.5, 10.4
Ants in the Garden – Object orientation case study. Sections 1.4, 3.5, 5.5, 6.4, 7.3, 10.4
Java API – Useful Java packages, Sections 3.4, 7.2, 8.3, 10.3

This is not a book that can be read through in an hour in the bath, as it is as much about ‘doing’ as it is reading. The accompanying website at www.soi.city.ac.uk/jpss includes exercises and quiz questions as well as further source code examples to download. By interacting with the materials both in the book and on the web, you will develop your programming skills and ‘way of thinking’, both vital to the successful manipulation of computing technology.
Those who have some programming experience may feel tempted to skip the early parts of the book. Of course, you are free to do so, but you may find it useful to attempt the exercises associated with each chapter, just to make sure you have not missed out on any key concepts.
To encourage an interactive use of this book, you will find short questions and simple exercises throughout its pages and on the web. You are encouraged to attempt these before moving on as they are designed to help reinforce key ideas.
Short questions will appear in a box like this. For example, consider why you wish to learn the Java language. Which of the six readers identified above (Sandra, Orlando, Sheila, Jay, Leo and Brian) do you most closely identify with?
At various stages, you will also come across ‘asides’ that explain related topics. These can be safely skipped without seriously damaging your health but are provided where it is thought that the background information might be useful in understanding the programming context.

Asides

Asides look like this. The Chambers English dictionary defines an aside as ‘words spoken in an undertone, so as not to be heard by some person present, words spoken by an actor which the other persons on the stage are supposed not to hear: an indirect effort of any kind’.
To encourage further interactivity, you can find a website to support this book at http://www.soi.city.ac.uk/jpss
Here you will find all the source code examples used in the book along with quiz questions, exercises and further Java resources to browse and download.
Frequent use of examples of Java code is made throughout this book. All Java code is shown in the Courier font in order to distinguish it from the commentary. Extended examples are shown as below and can also be downloaded from the website. Increasing reliance on examples will be made as you progress through this book and develop your Java reading skills.
// ***************************
/** Class for representing trees.
* @author Jo Wood
* @version 1.0, 14th May, 2001
*/
// ***************************
public class Tree
{
// -------------- Class and object variables -----------------
private float height; // Stores height of the tree.
// --------------------- Constructor -------------------------
/** Creates a new tree and gives it an initial height.
*/
public Tree()
{
height = 1; // Set initial height at 1m.
}
}
Finally, a glossary of terms can be found at the back of the book. This can be particularly useful if when reading the book you come across a term you have forgotten and wish to remind yourself of its meaning.

1.2 WHAT IS A PROGRAMMING LANGUAGE?

A natural language such as English, Portuguese or Hindi can be regarded as a combination of a vocabulary and set of grammatical rules that together facilitate communication. In order to be able to communicate, we need some idea of both the vocabulary and grammar. Language allows us to assemble our own ideas, convey them to other people and receive them from others. It provides a common framework for the organisation of ideas that two or more people can share.
A programming language is similar in that it allows communication between ourselves and the computers that share the common language. Even without communicating with a computer, programming languages can be useful to us as they allow us to assemble ideas in a structured way that can make future communication with a computer easier.
At the most detailed internal level, computers can only understand one language – binary instructions consisting of 1s and 0s (known as machine code). Most of us, on the other hand, cannot. We tend to think in far more abstract and ambiguous terms. Therefore, we need a ‘language’ that both the computer and ourselves can understand. We also need something to translate this language into the binary numbers that the computer works with.
Programming languages can therefore be placed on a scale somewhere between the computer’s representation of information and our own (see Figure 1.1).
image
Figure 1.1 The high-level – low-level programming continuum.
High-level languages can be regarded as ones that are closer to our way of thinking and organising ideas. They have the advantage of being relatively easy to use as they require less effort on our part to move between our own conceptualisations and those forced on us by the high-level language. They have the disadvantage of often being less flexible as they are usually designed to be applicable to a particular set of tasks (for example, a spreadsheet is useful for manipulating numerical information, but less so for the display of large amounts of text). You can think of using a GIS as programming in a high-level language because many of our ideas about spatial representation and analysis are already ‘encoded’ in the language of the GIS.
Low-level languages are closer to the binary representations used by all computers and are therefore more easily and efficiently translated into machine code. They tend to be more difficult for us to understand, but they can be flexible and powerful.
Java sits somewhere in the middle of the continuum containing many high-level concepts (such as objects, sounds and images) but structured in such a way as to allow efficient translation into a lower-level language.

1.3 PROGRAMMING STYLES

In the 1930s, the mathematician Alan Turing conceived of a machine, a machine that he (at that time) had no intention of building, nor indeed did he suggest, could be built (Figure 1.2). This machine, he imagined, consisted of a limitless stream of boxes arranged in a line, each of which was capable of storing a symbol of some kind. Associated with this line of boxes was a device that was able to identify the symbol in any single box, and, if necessary, substitute it for a new symbol. This device was capable of moving from one box to an adjacent one either to the ‘left’ or ‘right’.
image
Figure 1.2 A Turing machine.
The behaviour of the moveable device was governed by a series of rules that determined its movement and whether it changed the symbol stored in the box it was scanning. So, for example, we might define the following rules for the example illustrated in Figure 1.2.
If current box contains a circle, change it into a diamond and move right.
If current box contains an upward pointing triangle, change it into a circle and move right.
If current box contains a diamond, change it into a circle and move left.
If current box contains a downward pointing triangle, move right.
The Turing machine illustrates several important concepts fundamental to the way we interact with modern computers. First, that programming of a computer involves reading and manipulating some kind of data store (the line of boxes containing symbols). We can get the computer to remember things for us which we can later recall when necessary. Second, to use a data store effectively, we must provide a series of instructions that tell the computer how to interact with the stored information. Those instructions must be unambiguously expressed and can both influence and be influenced by the contents of the data store.

Turing Machines and Abstraction

Alan Turing’s conception of a machine that computes was made without any reference to how such machines would be built. It is a powerful example of abstraction, central to good object-oriented design, whereby we can remove the clutter associated with the mechanics of implementation in order to concentrate on what is done.
The fact that Turing’s contribution to computer science was so profound and influential at a time when the available technolo...

Table of contents

  1. Cover Page
  2. Title Page
  3. Copyright Page
  4. Figures
  5. Tables
  6. Preface
  7. Acknowledgements
  8. Chapter One: Introduction
  9. Chapter Two: Introducing Classes and Objects
  10. Chapter Three: Developing Classes and Objects
  11. Chapter Four: Controlling Program Movement
  12. Chapter Five: Making Decisions
  13. Chapter Six: Sharing Classes
  14. Chapter Seven: Collecting Objects Together
  15. Chapter Eight: Controlling Dynamic Events
  16. Chapter Nine: Handling Streams and Files
  17. Chapter Ten: Communicating with the Wider World
  18. References and Further Reading
  19. Glossary