diff --git a/CartoBaseElements.cpp b/CartoBaseElements.cpp index b44ab8d..038de93 100644 --- a/CartoBaseElements.cpp +++ b/CartoBaseElements.cpp @@ -198,9 +198,9 @@ double CartoBaseInfoEntity::disMedLines(SetPtsR *line2, double l_avan, double *d //***************************************************************************************** //la distancia media a una línea de longitud mayor que this, //calculando la distancia de los puntos de this a line2 -double CartoBaseInfoEntity::disMedLines(SetPtsR *line2, double *desv) +double CartoBaseInfoEntity::disMedLines(SetPtsR *line2, double *desv, BOOL usa_z /*= FALSE*/) { - return GeometryFunction::DisMedLines(this,line2); + return GeometryFunction::DisMedLines(this,line2, usa_z); } //***************************************************************************************** double *CartoBaseInfoEntity::GetPtoDis(double dis, double *dst, double *distTot) @@ -208,9 +208,9 @@ double *CartoBaseInfoEntity::GetPtoDis(double dis, double *dst, double *distTot) return GeometryFunction::GetPto(this, dis, dst, distTot); } //***************************************************************************************** -double CartoBaseInfoEntity::DisPtoLine(double*p, int* idpto, double *lamb) +double CartoBaseInfoEntity::DisPtoLine(double*p, int* idpto, double *lamb, BOOL usa_z) { - return GeometryFunction::DisPtoLine(this,p,idpto,lamb); + return GeometryFunction::DisPtoLine(this,p,idpto,lamb,usa_z); } //***************************************************************************************** double CartoBaseInfoEntity::DplineSeg(double* s1, double *s2,int *n, double *lamd1,double *lamb2) diff --git a/CartoBaseElements.h b/CartoBaseElements.h index eab9336..806ea37 100644 --- a/CartoBaseElements.h +++ b/CartoBaseElements.h @@ -111,8 +111,8 @@ public: void* getIa(); double getLong(); double disMedLines(SetPtsR *line2, double l_avan, double *desv=NULL); - double disMedLines(SetPtsR *line2, double *desv=NULL); - double DisPtoLine(double*p, int* idpto=NULL, double *lamb=NULL); + double disMedLines(SetPtsR *line2, double *desv=NULL, BOOL usa_z = FALSE); + double DisPtoLine(double*p, int* idpto=NULL, double *lamb=NULL, BOOL usa_z=FALSE); SetPtsW *GetNPrimePtos(SetPtsW *ldst, int nptos, double dis, BOOL avanza); bool DivLine(SetPtsW* ldst1, SetPtsW* ldst2, int ip, double lamb); double *GetPtoDis(double dis, double *dst, double *distTot); diff --git a/CartoElements.cpp b/CartoElements.cpp index f166591..2e3e7d2 100644 --- a/CartoElements.cpp +++ b/CartoElements.cpp @@ -188,8 +188,8 @@ void CartoLine::invert() //***************************************************************************************** //la distancia media a una línea de longitud mayor que this, //calculando la distancia de los puntos de this a line2 -double CartoEntity::disMedLines(SetPtsR *line2, double *desv) +double CartoEntity::disMedLines(SetPtsR *line2, double *desv, BOOL usa_z /*=FALSE*/) { - return GeometryFunction::DisMedLines(this,line2,desv); + return GeometryFunction::DisMedLines(this,line2,desv,usa_z); } //***************************************************************************************** \ No newline at end of file diff --git a/CartoElements.h b/CartoElements.h index aaffae3..449becf 100644 --- a/CartoElements.h +++ b/CartoElements.h @@ -31,7 +31,7 @@ public: virtual double* getPto(int i){return 0;} virtual int getNumberPtos(){return 0;} - virtual double disMedLines(SetPtsR *line2, double *desv=NULL); + virtual double disMedLines(SetPtsR *line2, double *desv=NULL, BOOL usa_z = FALSE); }; diff --git a/Fdbf.cpp b/Fdbf.cpp index 600e680..74c36db 100644 --- a/Fdbf.cpp +++ b/Fdbf.cpp @@ -166,9 +166,24 @@ __int64 Fdbf::getI64(int col) str[6] = 0; mm = atol(&str[4]); str[4] = 0; - aa = atol(str); - CTime tt(aa,mm,dd,0,0,0,-1); - return(tt.GetTime()); + aa = atol(str); + + try + { + CTime tt; + if (aa == 0 || mm == 0 || dd == 0) + tt = CTime::GetCurrentTime(); + else + { + CTime t2(aa, mm, dd, 0, 0, 0, -1); + tt = t2; + } + return(tt.GetTime()); + } + catch (...) + { + return 0; + } } //***************************************************************************************** bool Fdbf::set(int ncol, int nRow, Cb_file *file) diff --git a/GdataTable.cpp b/GdataTable.cpp index 28e40dc..c26b514 100644 --- a/GdataTable.cpp +++ b/GdataTable.cpp @@ -92,6 +92,7 @@ bool GdataTable::addColm(char* name, int type, int size) colmName.add(name); GdataTableColum inf; void* c = NULL; + inf.szascii = size; inf.flags=0; inf.nb=size; inf.type=type; @@ -111,7 +112,7 @@ bool GdataTable::addColm(char* name, int type, int size) break; case(Tint): c = new Cgarray(); - inf.nb = sizeof(long); + inf.nb = sizeof(long); if(nn>0) { if(!((*(Cgarray*)c)+=nn)) @@ -142,6 +143,8 @@ bool GdataTable::addColm(char* name, int type, int size) case(Tstring): case(Tbin): c = new Cgarray(); + if (!inf.nb) + inf.nb = 32; if(nn>0) { if(!((*(Cgarray*)c)+=(nn*inf.nb))) @@ -516,21 +519,23 @@ bool GdataTable::addMemRow( int nrow ) //*************************************************************************** int GdataTable::getSizeASCII( int icol ) { - if(!colm[icol].nb) + if (colm[icol].szascii) + return colm[icol].szascii; + else if(!colm[icol].nb) { switch(colm[icol].type) { case(Tbool): return 1; case(Tint): - return 4; + return 16; case(Tdouble): - return 8; + return 16; case(Tint64): - return 8; + return 32; case(Tbin): case(Tstring): - return colm[icol].nb; + return 32;// colm[icol].nb; default: return -1; } @@ -538,4 +543,5 @@ int GdataTable::getSizeASCII( int icol ) else return colm[icol].nb; } + //*************************************************************************** \ No newline at end of file diff --git a/GdataTable.h b/GdataTable.h index 920dd42..9d4b6e6 100644 --- a/GdataTable.h +++ b/GdataTable.h @@ -12,6 +12,7 @@ public: int type;//tipo de dato int nb;//numero de bytes de informacion int flags; + int szascii; //el tamaño en ascii que trae el dbf }; class UTILES_EXPORT GdataTable diff --git a/GeometryFunction.cpp b/GeometryFunction.cpp index 3ba6a59..feb856d 100644 --- a/GeometryFunction.cpp +++ b/GeometryFunction.cpp @@ -84,7 +84,8 @@ double GeometryFunction::DpSeg(double* s1, double *s2, double *p, double *lamb) return dis; } //***************************************************************************************** -double GeometryFunction::DisPtoLine(SetPtsR* line, double*p, int* idpto, double *lamb) +//si usa_z, descarta puntos de distinta z (los pone a dist infinita) +double GeometryFunction::DisPtoLine(SetPtsR* line, double*p, int* idpto, double *lamb, BOOL usa_z) { int nn = line->getNumberPtos(); double dis = DBL_MAX; @@ -105,6 +106,11 @@ double GeometryFunction::DisPtoLine(SetPtsR* line, double*p, int* idpto, double for(int i =1; igetPto(i); + if (usa_z) + { + if ((p[2] != p1[2]) || (p[2] != p2[2])) + return DBL_MAX; + } disa=DpSeg(p1,p2,p,&laux); if(disagetPto(i); - dis = DisPtoLine(line2,p); + dis = DisPtoLine(line2,p, NULL,NULL,usa_z); dd+=dis/n; dd2+=Poten(dis)/n; i++; diff --git a/GeometryFunction.h b/GeometryFunction.h index 90095c8..f156fc7 100644 --- a/GeometryFunction.h +++ b/GeometryFunction.h @@ -32,9 +32,9 @@ public: //calcula envoltura convexa static Cgarray* EnvConvex(SetPtsR* pts, Cgarray* dst); //distancia de un punto a una linea - static double DisPtoLine(SetPtsR* line, double*p, int* idpto=NULL, double *lamb=NULL); + static double DisPtoLine(SetPtsR* line, double*p, int* idpto=NULL, double *lamb=NULL, BOOL usa_z = FALSE); //distancia media entre dos líneas - static double DisMedLines( SetPtsR* line1, SetPtsR* line2, double *desv=NULL); + static double DisMedLines( SetPtsR* line1, SetPtsR* line2, double *desv=NULL, BOOL usa_z =FALSE); static double DisMedLines( SetPtsR* line1, SetPtsR* line2, double l_avan, double *desv=NULL); //parte una linea en 2 static bool DivLine(SetPtsR* linesrc, SetPtsW* ldst1, SetPtsW* ldst2, double dis); diff --git a/str_socket.cpp b/str_socket.cpp index 448f524..9c36f11 100644 --- a/str_socket.cpp +++ b/str_socket.cpp @@ -427,10 +427,26 @@ void Cstr_socket_srv::pon_tout( int t_out ) } //********************************************************************************************************************************** //********************************************************************************************************************************** -extern "C" UTILES_EXPORT BOOL str_socket_conecta( Cstr_socket *soc, char *ip, int puerto ) +extern "C" UTILES_EXPORT BOOL str_socket_conecta(Cstr_socket * soc, char* ip, int puerto, char* ip_local) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); - return soc->crear() && soc->conecta(ip, puerto); + BOOL b = TRUE; + int n = 1; + + + if (ip_local && ip_local[0] != 0) + { + do + { + b = soc->crear(ip_local, puerto + n); + n++; + } while (!b && n < 5); + if (!b) + int err = GetLastError(); + } + else + b = soc->crear(); + return b && soc->conecta(ip, puerto); } //********************************************************************************************************************************** extern "C" UTILES_EXPORT Cstr_socket * str_socket_crea() diff --git a/str_socket.h b/str_socket.h index 559f3fe..d541f30 100644 --- a/str_socket.h +++ b/str_socket.h @@ -79,7 +79,7 @@ public: }; //funciones de socket cliente para pinvoke----------------------------------------------------- extern "C" UTILES_EXPORT Cstr_socket *str_socket_crea(); -extern "C" UTILES_EXPORT BOOL str_socket_conecta(Cstr_socket *soc, char *ip, int puerto); +extern "C" UTILES_EXPORT BOOL str_socket_conecta(Cstr_socket *soc, char *ip, int puerto, char* ip_local=NULL); extern "C" UTILES_EXPORT BOOL str_socket_envia(Cstr_socket *soc, char *txt); extern "C" UTILES_EXPORT int str_socket_recive(Cstr_socket* soc); extern "C" UTILES_EXPORT void str_socket_dame_buf(Cstr_socket* soc, char* buf);