# Conflicts:
#	utiles.vcxproj
master
Gerardo 2023-04-19 15:18:29 +02:00
commit fde9722153
11 changed files with 70 additions and 26 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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);
}
//*****************************************************************************************

View File

@ -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);
};

View File

@ -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)

View File

@ -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<int>();
inf.nb = sizeof(long);
inf.nb = sizeof(long);
if(nn>0)
{
if(!((*(Cgarray<int>*)c)+=nn))
@ -142,6 +143,8 @@ bool GdataTable::addColm(char* name, int type, int size)
case(Tstring):
case(Tbin):
c = new Cgarray<char>();
if (!inf.nb)
inf.nb = 32;
if(nn>0)
{
if(!((*(Cgarray<char>*)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;
}
//***************************************************************************

View File

@ -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

View File

@ -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; i<nn; i++)
{
p2 = line->getPto(i);
if (usa_z)
{
if ((p[2] != p1[2]) || (p[2] != p2[2]))
return DBL_MAX;
}
disa=DpSeg(p1,p2,p,&laux);
if(disa<dis)
{
@ -344,7 +350,7 @@ double GeometryFunction::DisMedLines( SetPtsR* line1, SetPtsR* line2, double l_a
//*****************************************************************************************
//Siempre se le debe llamar de forma que line1 sea de menor longitud que line2
//calculando la distancia de los puntos de line1 a line2
double GeometryFunction::DisMedLines( SetPtsR* line1, SetPtsR* line2, double *desv/*=NULL*/)
double GeometryFunction::DisMedLines( SetPtsR* line1, SetPtsR* line2, double *desv/*=NULL*/, BOOL usa_z /*=FALSE*/)
{
double dis, dd, dd2;
int i,n;
@ -357,7 +363,7 @@ double GeometryFunction::DisMedLines( SetPtsR* line1, SetPtsR* line2, double *de
while(i<n)
{
p=line1->getPto(i);
dis = DisPtoLine(line2,p);
dis = DisPtoLine(line2,p, NULL,NULL,usa_z);
dd+=dis/n;
dd2+=Poten(dis)/n;
i++;

View File

@ -32,9 +32,9 @@ public:
//calcula envoltura convexa
static Cgarray<double[3]>* EnvConvex(SetPtsR* pts, Cgarray<double[3]>* 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);

View File

@ -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()

View File

@ -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);