Added wkb support to MYDDAS

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@2149 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
davidvaz 2008-03-13 18:31:05 +00:00
parent 2fe3053c78
commit abbfff0917

View File

@ -27,7 +27,7 @@ Term wkb2prolog(char *wkb) {
cursor = wkb;
/*ignorar o SRID 4 bytes*/
/*ignore the SRID 4 bytes*/
cursor += 4;
/*byteorder*/
@ -62,7 +62,6 @@ static byte get_inbyteorder(void){
exit(0);
}
/*avançar o cursor*/
cursor++;
return(b);
@ -105,7 +104,6 @@ static void readswap4(uint32 *buf){
}
}
/*avançar cursor*/
cursor += 4;
}
@ -149,7 +147,6 @@ static void readswap8(double *buf) {
}
}
/*avançar cursor*/
cursor += 8;
}
@ -185,17 +182,15 @@ static Term get_linestring(char *func){
/* read the number of vertices */
readswap4(&n);
/*alocar o espaço para os argumentos*/
/* space for arguments */
c_list = (Term *) calloc(sizeof(Term),n);
for ( i = 0; i < n; i++) {
c_list[i] = get_point(NULL);
}
/*criar a lista*/
list = MkAtomTerm(Yap_LookupAtom("[]"));
for (i = n - 1; i >= 0; i--) {
/*percorrer a lista em ordem inversa para o resultado ser o original*/
list = MkPairTerm(c_list[i],list);
}
@ -217,17 +212,15 @@ static Term get_polygon(char *func){
/* read the number of rings */
readswap4(&r);
/*alocar o espaço para os aneis*/
/* space for rings */
c_list = (Term *) calloc(sizeof(Term),r);
for ( i = 0; i < r; i++ ) {
c_list[i] = get_linestring(NULL);
}
/*criar a lista*/
list = MkAtomTerm(Yap_LookupAtom("[]"));
for (i = r - 1; i >= 0; i--) {
/*percorrer a lista em ordem inversa para o resultado ser o original*/
list = MkPairTerm(c_list[i],list);
}
@ -260,7 +253,7 @@ static Term get_geometry(uint32 type){
/* read the number of points */
readswap4(&n);
/*alocar o espaço para os pontos*/
/* space for points */
c_list = (Term *) calloc(sizeof(Term),n);
for ( i = 0; i < n; i++ ) {
@ -271,10 +264,8 @@ static Term get_geometry(uint32 type){
c_list[i] = get_point(NULL);
}
/*criar a lista*/
list = MkAtomTerm(Yap_LookupAtom("[]"));
for (i = n - 1; i >= 0; i--) {
/*percorrer a lista em ordem inversa para o resultado ser o original*/
list = MkPairTerm(c_list[i],list);
}
@ -296,7 +287,7 @@ static Term get_geometry(uint32 type){
/* read the number of polygons */
readswap4(&n);
/*alocar o espaço para os polygons*/
/* space for polygons*/
c_list = (Term *) calloc(sizeof(Term),n);
for ( i = 0; i < n; i++ ) {
@ -307,10 +298,8 @@ static Term get_geometry(uint32 type){
c_list[i] = get_linestring(NULL);
}
/*criar a lista*/
list = MkAtomTerm(Yap_LookupAtom("[]"));
for (i = n - 1; i >= 0; i--) {
/*percorrer a lista em ordem inversa para o resultado ser o original*/
list = MkPairTerm(c_list[i],list);
}
@ -332,7 +321,7 @@ static Term get_geometry(uint32 type){
/* read the number of polygons */
readswap4(&n);
/*alocar o espaço para os polygons*/
/* space for polygons*/
c_list = (Term *) calloc(sizeof(Term),n);
for ( i = 0; i < n; i++ ) {
@ -343,10 +332,8 @@ static Term get_geometry(uint32 type){
c_list[i] = get_polygon(NULL);
}
/*criar a lista*/
list = MkAtomTerm(Yap_LookupAtom("[]"));
for (i = n - 1; i >= 0; i--) {
/*percorrer a lista em ordem inversa para o resultado ser o original*/
list = MkPairTerm(c_list[i],list);
}
@ -367,7 +354,7 @@ static Term get_geometry(uint32 type){
/* read the number of geometries */
readswap4(&n);
/*alocar o espaço para as geometrys*/
/* space for geometries*/
c_list = (Term *) calloc(sizeof(Term),n);
@ -376,10 +363,8 @@ static Term get_geometry(uint32 type){
c_list[i] = get_geometry(get_wkbType());
}
/*criar a lista*/
list = MkAtomTerm(Yap_LookupAtom("[]"));
for (i = n - 1; i >= 0; i--) {
/*percorrer a lista em ordem inversa para o resultado ser o original*/
list = MkPairTerm(c_list[i],list);
}