Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- gcc -Wall -std=c++17 -I. -L. -llibgeos_c geos-test.cpp -o geos-test.exe
- */
- #include <cstdio>
- #include <cstdlib>
- #include <iostream>
- //#include "OraOLEDB.h"
- #include "geos_c.h"
- #include "proj.h"
- using namespace std;
- char prop(GEOSGeometry *g) {
- cout<< "GeomType: "<<GEOSGeomType(g)<<endl;
- GEOSisEmpty(g) ? cout<<"isEmpty! " : cout<<"Not Empty! "; cout<<endl;
- GEOSisValid(g) ? cout<<"isValid! " : cout<<"Not Valid! "; cout<<endl;
- GEOSisSimple(g) ? cout<<"isSimple!" : cout<<"Not Simple!"; cout<<endl;
- GEOSisRing(g) ? cout<<"isRing! " : cout<<"Not Ring! "; cout<<endl;
- GEOSHasZ(g) ? cout<<"HasZ! " : cout<<"Hasn't Z! "; cout<<endl;
- cout<<endl;
- return 1;
- }
- int main() {
- cout<<"Fordítás: "<<__DATE__<<" "<<__TIME__<<endl;
- cout<<"Geos: "<<GEOSversion()<<endl<<endl;
- initGEOS(NULL,NULL);
- GEOSGeometry *g;
- GEOSGeometry *l, *l1, *l2, *lx;
- //GEOSGeometry *p;
- g = GEOSGeomFromWKT("POINT(0 0)"); prop(g);
- l = GEOSGeomFromWKT("LINESTRING(0 0,1 1,1 2)"); prop(l);
- l1 = GEOSGeomFromWKT("LINESTRING(0 0,10 10)"); prop(l1);
- l2 = GEOSGeomFromWKT("LINESTRING(0 10,10 0)"); prop(l2);
- lx = GEOSIntersection(l1, l2);
- //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);
- cout<<GEOSGeomToWKT(g)<<endl;
- cout<<GEOSGeomToWKT(l)<<endl;
- cout<<GEOSGeomToWKT(l1)<<endl;
- cout<<GEOSGeomToWKT(l2)<<endl;
- cout<<GEOSGeomToWKT(lx)<<endl;
- GEOSIntersects(l1, l2) ? cout<<"\nTalálkoztak!\n\n" : cout<<"\nNem találkoztak...\n\n";
- //cout<<GEOSGeomToWKT(p)<<endl;
- /*
- unsigned int npoints, ndims;
- npoints = GEOSGetNumCoordinates(g);
- ndims = GEOSGeom_getDimensions(g);
- printf("Geometry coordinates: %dx%d\n", npoints, ndims);
- */
- //double *terulet, *hossz;
- //int ret;
- //ret=GEOSArea(p,terulet)<<endl;
- //cout<<terulet<<endl;
- //ret=GEOSLength(l, hossz);
- //cout<<hossz<<endl;
- // GEOSDistance(const GEOSGeometry* g1, const GEOSGeometry* g2, double *dist);
- //GEOSCoordSequence *gs;
- //gs = GEOSCoordSeq_create(1, 2);
- //cout<<GEOSCoordSeq_setX(gs,50,750000)<<endl;
- //cout<<GEOSCoordSeq_setY(gs,40,175000)<<endl;
- //cout<<GEOSCoordSeq_setZ(gs,30,110)<<endl;
- //g=GEOSGeom_createPoint(gs);
- finishGEOS();
- cin.get();
- return 0;
- }
- //http://www.opengeospatial.org/standards/geoapi
- //http://osgeo.org.cn/l18n/geodjango/geos.html
- // http://www.cs.nyu.edu/courses/spring05/V22.0201-001/c_tutorial/classes/String.html
- //http://web.cs.wpi.edu/~cs1005/common/floatformats.html
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement