Advertisement
kijato

geos & proj teszt

Jun 4th, 2020
1,152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.50 KB | None | 0 0
  1. /*
  2.     gcc -Wall -std=c++17 -I. -L. -llibgeos_c geos-test.cpp -o geos-test.exe
  3. */
  4. #include <cstdio>
  5. #include <cstdlib>
  6. #include <iostream>
  7. //#include "OraOLEDB.h"
  8. #include "geos_c.h"
  9. #include "proj.h"
  10.  
  11. using namespace std;
  12.  
  13. char prop(GEOSGeometry *g) {
  14.   cout<< "GeomType: "<<GEOSGeomType(g)<<endl;
  15.   GEOSisEmpty(g)  ? cout<<"isEmpty! " : cout<<"Not Empty! "; cout<<endl;
  16.   GEOSisValid(g)  ? cout<<"isValid! " : cout<<"Not Valid! "; cout<<endl;
  17.   GEOSisSimple(g) ? cout<<"isSimple!" : cout<<"Not Simple!"; cout<<endl;
  18.   GEOSisRing(g)   ? cout<<"isRing!  " : cout<<"Not Ring!  "; cout<<endl;
  19.   GEOSHasZ(g)     ? cout<<"HasZ!    " : cout<<"Hasn't Z!  "; cout<<endl;
  20.   cout<<endl;
  21.   return 1;
  22. }
  23.  
  24. int main() {
  25.   cout<<"Fordítás: "<<__DATE__<<" "<<__TIME__<<endl;
  26.   cout<<"Geos:     "<<GEOSversion()<<endl<<endl;
  27.  
  28.   initGEOS(NULL,NULL);
  29.  
  30.   GEOSGeometry *g;
  31.   GEOSGeometry *l, *l1, *l2, *lx;
  32.   //GEOSGeometry *p;
  33.   g = GEOSGeomFromWKT("POINT(0 0)"); prop(g);
  34.   l = GEOSGeomFromWKT("LINESTRING(0 0,1 1,1 2)"); prop(l);
  35.   l1 = GEOSGeomFromWKT("LINESTRING(0 0,10 10)"); prop(l1);
  36.   l2 = GEOSGeomFromWKT("LINESTRING(0 10,10 0)"); prop(l2);
  37.   lx = GEOSIntersection(l1, l2);
  38.  
  39.   //p = GEOSGeomFromWKT("POLYGON((0 0,4 0,4 4,0 4,0 0),(1 1, 2 1, 2 2, 1 2,1 1))"); prop(p);
  40.  
  41.   cout<<GEOSGeomToWKT(g)<<endl;
  42.   cout<<GEOSGeomToWKT(l)<<endl;
  43.   cout<<GEOSGeomToWKT(l1)<<endl;
  44.   cout<<GEOSGeomToWKT(l2)<<endl;
  45.   cout<<GEOSGeomToWKT(lx)<<endl;
  46.   GEOSIntersects(l1, l2) ? cout<<"\nTalálkoztak!\n\n" : cout<<"\nNem találkoztak...\n\n";
  47.   //cout<<GEOSGeomToWKT(p)<<endl;
  48.  
  49. /*
  50.     unsigned int npoints, ndims;
  51.     npoints = GEOSGetNumCoordinates(g);
  52.     ndims = GEOSGeom_getDimensions(g);
  53.     printf("Geometry coordinates: %dx%d\n", npoints, ndims);
  54. */
  55.  
  56.   //double *terulet, *hossz;
  57.   //int ret;
  58.   //ret=GEOSArea(p,terulet)<<endl;
  59.   //cout<<terulet<<endl;
  60.   //ret=GEOSLength(l, hossz);
  61.   //cout<<hossz<<endl;
  62. //  GEOSDistance(const GEOSGeometry* g1, const GEOSGeometry* g2, double *dist);
  63.  
  64.  
  65.   //GEOSCoordSequence *gs;
  66.  
  67.   //gs = GEOSCoordSeq_create(1, 2);
  68.   //cout<<GEOSCoordSeq_setX(gs,50,750000)<<endl;
  69.   //cout<<GEOSCoordSeq_setY(gs,40,175000)<<endl;
  70.   //cout<<GEOSCoordSeq_setZ(gs,30,110)<<endl;
  71.  
  72.   //g=GEOSGeom_createPoint(gs);
  73.  
  74.   finishGEOS();
  75.   cin.get();
  76.   return 0;
  77. }
  78.  
  79.  
  80. //http://www.opengeospatial.org/standards/geoapi
  81. //http://osgeo.org.cn/l18n/geodjango/geos.html
  82.  
  83. // http://www.cs.nyu.edu/courses/spring05/V22.0201-001/c_tutorial/classes/String.html
  84. //http://web.cs.wpi.edu/~cs1005/common/floatformats.html
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement