1 / 13

GIS Application Development

GIS Application Development. Using Libraries. What are (programming) Libraries?. NOT Buildings or Rooms in Universities!! But, they are COLLECTIONS of works Highly Specialized Indexed by Topic. High-Level Routines. Sample Library. OPTION BASE 1 DIM x(1 TO 7) AS SINGLE

harvey
Download Presentation

GIS Application Development

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. GIS Application Development Using Libraries

  2. What are (programming) Libraries? • NOT Buildings or Rooms in Universities!! • But, they are COLLECTIONS of works • Highly Specialized • Indexed by Topic

  3. High-Level Routines

  4. Sample Library

  5. OPTION BASE 1 DIM x(1 TO 7) AS SINGLE DIM y(1 TO 7) AS SINGLE DIM nearst(1 TO 7) AS SINGLE DIM nearmean AS SINGLE DIM dist AS SINGLE DIM xmean AS SINGLE DIM ymean AS SINGLE DIM Npts AS INTEGER 'a DATA statement is used to store ‘information inside the program DATA 2,3,2,7,3,6,6,5,8,5,8,4,7,1 Npts = 7 FOR i = 1 TO Npts ' a READ statement gets data READ x(i), y(i) NEXT i

  6. 'example call to "library routine: geoMeanXY ' CALL geoMeanXY(x(), y(), Npts, xmean, ymean) PRINT "Mean of X and Y "; xmean, ymean

  7. SUB geoMeanXY (x() AS SINGLE, y() AS SINGLE, Npts AS INTEGER, xmean AS SINGLE, ymean AS SINGLE) ' 'This routine finds the Mean X,Y Value for a set of points p1,p2 .. pn 'With coordinates x1,y1,...xn,yn 'Requires the Number of points in the set (Npts) ' 'USES mthMean(v() as single, n as integer, vmean as Single) 'Returns the Arithmetic Mean of the X and Y coordinates CALL mthMean(x(), Npts, xmean) CALL mthMean(y(), Npts, ymean) END SUB

  8. SUB mthMean (var() AS SINGLE, N AS INTEGER, varmean AS SINGLE) 'Calculates Arithmetic Mean of a Variable (var) with dimension N ' varmean = 0 FOR i = 1 TO N varmean = varmean + var(i) NEXT i varmean = varmean / N END SUB

  9. CALL geoNeighbor(x(), y(), Npts, nearst()) FOR i = 1 TO Npts PRINT "Nearest Neighbor ", i, nearst(i) NEXT i

  10. SUB geoNeighbor (x() AS SINGLE, y() AS SINGLE, Npts AS INTEGER, nearst() AS SINGLE) DIM tdist AS SINGLE ' 'This routine calculates the Nearest Neighbor Matrix for a Set of points 'Each point is represented by its X,Y coordinates 'Npts is the number of points in the set ' 'Returns the Array nearst(Npts) of Nearest Neighbor Distance for each point

  11. FOR i = 1 TO Npts ' for each point set the nearest value to a ridiculously high number nearst(i) = 1E+07 ' FOR j = 1 TO Npts tdist = 0 IF i <> j THEN CALL geoDist2D(x(i), y(i), x(j), y(j), tdist) IF tdist < nearst(i) THEN nearst(i) = tdist END IF END IF NEXT j NEXT i END SUB

  12. SUB geoDist2D (x1 AS SINGLE, y1 AS SINGLE, x2 AS SINGLE, y2 AS SINGLE, dist AS SINGLE) ' 'This routine accepts two points (p1, p2) with coordinates x1,y1 and x2,y2 'And Returns the euclidean distance between them ' dist = ((x2 - x1) ^ 2) + ((y2 - y1) ^ 2) dist = SQR(dist) END SUB

  13. 'Calculate Mean Nearest Neighbor CALL mthMean(nearst(), Npts, nearmean) PRINT "Mean Nearest Neighbor "; nearmean

More Related