Mapdraw ats315. Today’s goal: Drawing a map in the graphics window! Drawing a map in the graphics window!

Slides:



Advertisements
Similar presentations
ECS 15 if and random. Topic  Testing user input using if statements  Truth and falsehood in Python  Getting random numbers.
Advertisements

Foreknowledge and free will God is essentially omniscient. So assuming that there are facts about the future, then God knows them. And it’s impossible.
1.6 Inverse Functions Students will find inverse functions informally and verify that two functions are inverse functions of each other. Students will.
Developing your Assessment Judy Cohen Curriculum Developer Unit for the Enhancement of Learning and Teaching.
Latitude and Longitude:
Week 9: Methods 1.  We have written lots of code so far  It has all been inside of the main() method  What about a big program?  The main() method.
CSE332: Data Abstractions Lecture 25: There is no lecture 25 Dan Grossman Spring 2010.
1 of 19 New Lecture And Lab Information Lectures: –Thursday 13:00 – 14:00 (A322) Does anyone miss lunch? –Friday 15:00 – 16:00 (A28) Labs: –Wednesday 10:00.
Today’s quiz on 8.2 A Graphing Worksheet 1 will be given at the end of class. You will have 12 minutes to complete this quiz, which will consist of one.
ECE122 L17: Method Development and Testing April 5, 2007 ECE 122 Engineering Problem Solving with Java Lecture 17 Method Development and Testing.
Graphing Linear Equations in Two Variables The Graph of a linear equation in two variables is the graph of all the ordered pairs (x,y) that satisfy the.
Learning about Latitude and Longitude
Social Interactions: Inviting & Responding to Invitations
Latitude / Longitude Lat/lon practice map. The Equator and Parallels of Latitude.
0.1 Functions and Their Graphs. Real Numbers A set is a collection of objects. The real numbers represent the set of numbers that can be represented as.
Files COP3275 – PROGRAMMING USING C DIEGO J. RIVERA-GUTIERREZ.
Computing Science 1P Lecture 13: Friday 26 th January Simon Gay Department of Computing Science University of Glasgow 2006/07.
CS 4730 Ruminations on Sprites in Monogame Martin Kellogg, definitely not Ph.D.
Files Working with Files in C ATS 315. Files Misunderstandings about “files” In Windows and on Macs, we tend to think of files as “containing something”.
CSC 107 – Programming For Science. Today’s Goal  Discuss writing & using functions  How to declare them, use them, & trace them  Could write programs.
Programming Training kiddo Main Points: - Python Statements - Problems with selections.
Fall Week 3 CSCI-141 Scott C. Johnson.  Say we want to draw the following figure ◦ How would we go about doing this?
Contouring in C ATS 315. How Contours Really Work Contours may LOOK like curves, but they are really just straight line segments.
به نام خدا تنظیم کننده : فرانه حدادی استاد : مهندس زمانیان تابستان 92.
1 Peter Fox GIS for Science ERTH 4750 (98271) Week 10, Friday, April 6, 2012 Lab:
Latitude and Longitude: Finding Locations on Planet Earth. With thanks and credit to Step.com.
Graphic Basics in C ATS 315. The Graphics Window Will look something like this.
CS 101: Introduction to Computing Color replacements and targeted color replacement (if statement) Developed by Mark Guzdial, Georgia Institute of Technology,
Data Creation and Editing Based in part on notes by Prof. Joseph Ferreira and Michael Flaxman Lulu Xue | Nov. 3, :A Workshop on Geographical.
Arrays and Assignment 12 ATS 315 Jon Schrage (2008)
1 Project 5: Printing Address Labels. 2 Assignment Write a Windows forms program to display and print a set of address labels. Input from a csv file.
Texture Mapping CAP4730: Computational Structures in Computer Graphics.
Computer Graphics 3D Transformations. Translation.
CRE Programming Club Class 3 (Install Small Basic on the new computers! Double-click on I:/smallbasic.msi)
CSS 290: Video Games and Computer Programming. CSS 2902 Reading: Conditional Statements PLAD Ch 4 –The objective for this book is to provide you with.
Pop-Up Menus Glenn G. Chappell U. of Alaska Fairbanks CS 381 Lecture Notes Friday, September 26, 2003.
Week 9 : Text processing (Reading and writing files)
Let’s Look at This Question: How is latitude measured?
1 Project 2: Using Variables and Expressions. 222 Project 2 Overview For this project you will work with three programs Circle Paint Ideal_Weight What.
Creating Data Sheets. When you see a Red circle or a next button, like this, that means we want you to click on something. These are the same steps you’ll.
Logical Operators.  Quiz  Let's look at the schedule  Logical Operators 2.
Objective Analysis ATS 315. Objective Analysis  Converting irregularly distributed data to a uniform 2-D grid.
Today… Modularity, or Writing Functions. Winter 2016CISC101 - Prof. McLeod1.
Large Datasets and Path Mapping in Tableau A V Flinsch Information Visualization Fall 2015.
Quiz 3 Topics Functions – using and writing. Lists: –operators used with lists. –keywords used with lists. –BIF’s used with lists. –list methods. Loops.
Inverses are everywhere – when we think about reversing a process, we are thinking about the inverse.
Next Week… Quiz 2 next week: –All Python –Up to this Friday’s lecture: Expressions Console I/O Conditionals while Loops Assignment 2 (due Feb. 12) topics:
Geocoding Chapter 16 GISV431 &GEN405 Dr W Britz. Georeferencing, Transformations and Geocoding Georeferencing is the aligning of geographic data to a.
Geocoding Chapter 16 GISV431 &GEN405 Dr W Britz. Georeferencing, Transformations and Geocoding Georeferencing is the aligning of geographic data to a.
COMP261 Lecture 4 Graphs 3 of 3.
User-Written Functions
Bell Assignment Pick up a pre-assessment Map Quiz from the front of the room and complete it on your own! This is NOT for a grade, this is to see how.
Finding Locations on Planet Earth
Control structures Chapter 3.
Latitude / Longitude.
Downloading and Preparing GIS Precipitation Data Layers
Preliminaries: -- vector, raster, shapefiles, feature classes.
Lecturer: Mukhtar Mohamed Ali “Hakaale”
Latitude and Longitude:
Coordinate Reference Systems
Leaflet maps in R Gene Leynes
Latitude and Longitude:
Getting Started with Milestone 2
Latitude and Longitude:
Functions and Graphing
Java Programming Language
Relations And Functions.
Latitude and Longitude:
Latitude and Longitude:
Presentation transcript:

mapdraw ats315

Today’s goal: Drawing a map in the graphics window! Drawing a map in the graphics window!

Previous Skills: Basic graphic commands (opening windows, drawing lines) Basic graphic commands (opening windows, drawing lines) Reading files Reading files The “while” statement The “while” statement functions functions

The Map Files state.ats315.dat state.ats315.dat –nice state outlines usa_cnty.ats315.dat usa_cnty.ats315.dat –nice county outlines rd_int.ats315.dat rd_int.ats315.dat –U.S. Interstate Highways rivermap.ats315.dat rivermap.ats315.dat –major U.S. rivers

Where are the map files? /usr/local/wxp/etc/ /usr/local/wxp/etc/

How the map files work: They are collections of line segments. They are collections of line segments. lat1 lon1 lat2 lon2 lat1 lon1 lat2 lon2 You don’t know in advance how many line segments there will be. You don’t know in advance how many line segments there will be.

Reading the map file: while (!feof(fmap)) { fscanf (fmap, “%f %f %f %f”,&lat1, &lon1, &lat2, &lon2); /* Now do stuff with this information */ }

Reading the map file: What to do with these lats and lons is the tricky part! What to do with these lats and lons is the tricky part! while (!feof(fmap)) { fscanf (fmap, “%f %f %f %f”,&lat1, &lon1, &lat2, &lon2); /* Now do stuff with this information */ }

Why this is tricky: The map file is full of latitudes and longitudes of the line segments that make up the map. The map file is full of latitudes and longitudes of the line segments that make up the map. Your graphics window is NOT expressed in terms of latitude and longitude—rather it is a unit square! Your graphics window is NOT expressed in terms of latitude and longitude—rather it is a unit square! Therefore, you need to transform (lat,lon) into (x,y). Therefore, you need to transform (lat,lon) into (x,y).

Transforming coordinates: Is best done in a function. Is best done in a function. Can be done in two functions, but I’d prefer to see you do it with just one. Can be done in two functions, but I’d prefer to see you do it with just one.

Transformations: Latitude corresponds to the y direction. Latitude corresponds to the y direction. Longitude corresponds to the x direction. Longitude corresponds to the x direction.

Transformations: Let’s focus on LATITUDE first. Let’s focus on LATITUDE first.

Transformations: You need some kind of function that converts the latitude to a number between 0 and 1. You need some kind of function that converts the latitude to a number between 0 and 1.

Transformations: More to the point, you need this function to convert JUST THE PART OF THE MAP YOU WANT to a number between 0 and 1. More to the point, you need this function to convert JUST THE PART OF THE MAP YOU WANT to a number between 0 and 1.

Transformations: For example, here clearly some latitudes are outside the (0,1) range for y, and so they aren’t plotted. For example, here clearly some latitudes are outside the (0,1) range for y, and so they aren’t plotted.

Transformations: You could write a function called transformlatitude(lat). You could write a function called transformlatitude(lat).

Transformations: Your “northernmost” latitude becomes 1. Your “northernmost” latitude becomes 1. YOU get to pick your northernmost latitude! YOU get to pick your northernmost latitude!

Transformations: Your “southernmost” latitude becomes 0. Your “southernmost” latitude becomes 0. YOU get to pick your southernmost latitude! YOU get to pick your southernmost latitude!

Transformations: Could look something like this: float transformlatitude(float lat) { float northernmost, southernmost. y; northernmost = 40.; southernmost = 30.; y = (lat – southernmost) / (northernmost – southernmost); return y; }

Transformations: Interpolates your “lat” between 0 and 1 if it is between northernmost and southernmost: float transformlatitude(float lat) { float northernmost, southernmost. y; northernmost = 40.; southernmost = 30.; y = (lat – southernmost) / (northernmost – southernmost); return y; }

Transformations: Then your map reading program could call transformlatitude to get a value on the unit square: while (!feof(fmap)) { fscanf (fmap, “%f %f %f %f”,&lat1, &lon1, &lat2, &lon2); y1 = transformlatitude (lat1); y2 = transformlatitude (lat2); /* Now do this with the longitudes as well! */ /* Now do stuff with this information */ }

Transformations: A similar function could be written for longitudes then: while (!feof(fmap)) { fscanf (fmap, “%f %f %f %f”,&lat1, &lon1, &lat2, &lon2); y1 = transformlatitude (lat1); y2 = transformlatitude (lat2); x1 = transformlongitude (lon1); x2 = transformlongitude (lon2); /* Now do stuff with this information */ }

Transformations: Then decide what you are going to do with this new (x1,y1) and (x2,y2)! while (!feof(fmap)) { fscanf (fmap, “%f %f %f %f”,&lat1, &lon1, &lat2, &lon2); y1 = transformlatitude (lat1); y2 = transformlatitude (lat2); x1 = transformlongitude (lon1); x2 = transformlongitude (lon2); /* Now do stuff with this information */ }

Ideally… you really should use just ONE function to transform the latitudes and longitudes into x and y: you really should use just ONE function to transform the latitudes and longitudes into x and y: transform(lat,lon,x,y); transform(lat,lon,x,y); But, to do this, you’ll need to think VERY carefully about which parameters are passed by VALUE and which are passed by ADDRESS! But, to do this, you’ll need to think VERY carefully about which parameters are passed by VALUE and which are passed by ADDRESS!

Which one is it? transform(lat,lon,x,y); transform(lat,lon,x,y); transform(&lat,&lon,x,y); transform(&lat,&lon,x,y); transform(lat,lon,&x,&y); transform(lat,lon,&x,&y); transform(&lat,&lon,&x,&y); transform(&lat,&lon,&x,&y); Or even something else???? Or even something else????

Your Assignment: There is no specific assignment about this lecture. There is no specific assignment about this lecture. You DO have to draw a map—with “clipping”—for Friday. You DO have to draw a map—with “clipping”—for Friday. Therefore, start working on this NOW! Therefore, start working on this NOW!