示例#1
0
static Shape Shape77As22( // return an approximated AR 22 point shape
    const Shape& shape)   // in: Stasm 77 point shape
{
    CV_Assert(shape.rows == 77);

    // first 20 points same as BioId
    Shape newshape = DimKeep(Shape77As20(shape), 22, 2);

    CopyPoint(newshape, shape, 20, 3);
    CopyPoint(newshape, shape, 21, 9);

    return newshape;
}
void QgsMssqlGeometryParser::ReadMultiPoint(int iShape)
{
    int iFigure, iPoint, iNextPoint, iCount;
    iFigure = FigureOffset(iShape);
    iNextPoint = NextPointOffset(iFigure);
    iCount = iNextPoint - PointOffset(iFigure);
    if (iCount <= 0)
        return;
    // copy byte order
    CopyBytes( &chByteOrder, 1 );
    // copy type
    int wkbType;
    if ( chProps & SP_HASZVALUES )
        wkbType = QGis::WKBMultiPoint25D;
    else
        wkbType = QGis::WKBMultiPoint;
    CopyBytes( &wkbType, 4 );
    // copy point count
    CopyBytes( &iCount, 4 );
    // copy points
    for (iPoint = PointOffset(iFigure); iPoint < iNextPoint; iPoint++)
    {
        CopyPoint(iShape);
    }
}
示例#3
0
void QgsMssqlGeometryParser::ReadPoint( int iShape )
{
  int iFigure = FigureOffset( iShape );
  if ( iFigure < nNumFigures )
  {
    int iPoint = PointOffset( iFigure );
    if ( iPoint < nNumPoints )
    {
      CopyPoint( iPoint );
    }
  }
}
示例#4
0
static Shape Shape77As76( // return an approximated MUCT 76 point shape
    const Shape& shape)   // in: Stasm 77 point shape
{
    // first 68 points same as XM2VTS
    Shape newshape = DimKeep(Shape77AsXm2vts68(shape), 76, 2);

    CopyPoint(newshape,  shape, 68, 33); // extra eyelid points
    CopyPoint(newshape,  shape, 69, 31);
    CopyPoint(newshape,  shape, 70, 37);
    CopyPoint(newshape,  shape, 71, 35);
    CopyPoint(newshape,  shape, 72, 43);
    CopyPoint(newshape,  shape, 73, 41);
    CopyPoint(newshape,  shape, 74, 47);
    CopyPoint(newshape,  shape, 75, 45);

    return newshape;
}
示例#5
0
unsigned char* QgsMssqlGeometryParser::ParseSqlGeometry( unsigned char* pszInput, int nLen )
{
  if ( nLen < 10 )
  {
    QgsDebugMsg( "ParseSqlGeometry not enough data" );
    DumpMemoryToLog( "Not enough data", pszInput, nLen );
    return NULL;
  }

  pszData = pszInput;
  nWkbMaxLen = nLen;

  /* store the SRS id for further use */
  nSRSId = ReadInt32( 0 );

  if ( ReadByte( 4 ) != 1 )
  {
    QgsDebugMsg( "ParseSqlGeometry corrupt data" );
    DumpMemoryToLog( "Corrupt data", pszInput, nLen );
    return NULL;
  }

  chProps = ReadByte( 5 );

  if ( chProps & SP_HASZVALUES && chProps & SP_HASMVALUES )
    nPointSize = 32;
  else if ( chProps & SP_HASZVALUES || chProps & SP_HASMVALUES )
    nPointSize = 24;
  else
    nPointSize = 16;

  /* store byte order */
  chByteOrder = QgsApplication::endian();

  pszWkb = new unsigned char[nLen]; // wkb should be less or equal in size
  nWkbLen = 0;

  if ( chProps & SP_ISSINGLEPOINT )
  {
    // single point geometry
    nNumPoints = 1;
    nPointPos = 6;

    if ( nLen < 6 + nPointSize )
    {
      delete [] pszWkb;
      QgsDebugMsg( "ParseSqlGeometry not enough data" );
      DumpMemoryToLog( "Not enough data", pszInput, nLen );
      return NULL;
    }

    CopyPoint( 0 );
  }
  else if ( chProps & SP_ISSINGLELINESEGMENT )
  {
    // single line segment with 2 points
    nNumPoints = 2;
    nPointPos = 6;

    if ( nLen < 6 + 2 * nPointSize )
    {
      delete [] pszWkb;
      QgsDebugMsg( "ParseSqlGeometry not enough data" );
      DumpMemoryToLog( "Not enough data", pszInput, nLen );
      return NULL;
    }

    // copy byte order
    CopyBytes( &chByteOrder, 1 );
    // copy type
    int wkbType;
    if ( chProps & SP_HASZVALUES )
      wkbType = QGis::WKBLineString25D;
    else
      wkbType = QGis::WKBLineString;
    CopyBytes( &wkbType, 4 );
    // copy point count
    int iCount = 2;
    CopyBytes( &iCount, 4 );
    // copy points
    CopyCoordinates( 0 );
    CopyCoordinates( 1 );
  }
  else
  {
    // complex geometries
    nNumPoints = ReadInt32( 6 );

    if ( nNumPoints <= 0 )
    {
      delete [] pszWkb;
      return NULL;
    }

    // position of the point array
    nPointPos = 10;

    // position of the figures
    nFigurePos = nPointPos + nPointSize * nNumPoints + 4;

    if ( nLen < nFigurePos )
    {
      delete [] pszWkb;
      QgsDebugMsg( "ParseSqlGeometry not enough data" );
      DumpMemoryToLog( "Not enough data", pszInput, nLen );
      return NULL;
    }

    nNumFigures = ReadInt32( nFigurePos - 4 );

    if ( nNumFigures <= 0 )
    {
      delete [] pszWkb;
      return NULL;
    }

    // position of the shapes
    nShapePos = nFigurePos + 5 * nNumFigures + 4;

    if ( nLen < nShapePos )
    {
      delete [] pszWkb;
      QgsDebugMsg( "ParseSqlGeometry not enough data" );
      DumpMemoryToLog( "Not enough data", pszInput, nLen );
      return NULL;
    }

    nNumShapes = ReadInt32( nShapePos - 4 );

    if ( nLen < nShapePos + 9 * nNumShapes )
    {
      delete [] pszWkb;
      QgsDebugMsg( "ParseSqlGeometry not enough data" );
      DumpMemoryToLog( "Not enough data", pszInput, nLen );
      return NULL;
    }

    if ( nNumShapes <= 0 )
    {
      delete [] pszWkb;
      return NULL;
    }

    // pick up the root shape
    if ( ParentOffset( 0 ) != 0xFFFFFFFF )
    {
      delete [] pszWkb;
      QgsDebugMsg( "ParseSqlGeometry corrupt data" );
      DumpMemoryToLog( "Not enough data", pszInput, nLen );
      return NULL;
    }

    // determine the shape type
    switch ( ShapeType( 0 ) )
    {
      case ST_POINT:
        ReadPoint( 0 );
        break;
      case ST_LINESTRING:
        ReadLineString( 0 );
        break;
      case ST_POLYGON:
        ReadPolygon( 0 );
        break;
      case ST_MULTIPOINT:
        ReadMultiPoint( 0 );
        break;
      case ST_MULTILINESTRING:
        ReadMultiLineString( 0 );
        break;
      case ST_MULTIPOLYGON:
        ReadMultiPolygon( 0 );
        break;
        //case ST_GEOMETRYCOLLECTION:
        //ReadGeometryCollection(0);
        //break;
      default:
        delete [] pszWkb;
        QgsDebugMsg( "ParseSqlGeometry unsupported geometry type" );
        DumpMemoryToLog( "Unsupported geometry type", pszInput, nLen );
        return NULL;
    }
  }

  return pszWkb;
}
示例#6
0
static Shape Shape77AsXm2vts68( // return an approximated XM2VTS 68 point shape
    const Shape& shape)         // in: Stasm 77 point shape
{
    CV_Assert(shape.rows == 77);

    Shape newshape(68, 2);

    CopyPoint(newshape,  shape,  0,  0);
    InterPoint(newshape, shape,  1, .6667, 1, 2);
    InterPoint(newshape, shape,  2, .5,    2, 3);
    CopyPoint(newshape,  shape,  3,  3);
    InterPoint(newshape, shape,  4, .3333, 3, 4);
    InterPoint(newshape, shape,  5, .6667, 4, 5);
    CopyPoint(newshape,  shape,  6,  5);
    CopyPoint(newshape,  shape,  7,  6);
    CopyPoint(newshape,  shape,  8,  7);
    InterPoint(newshape, shape,  9, .3333, 7, 8);
    InterPoint(newshape, shape, 10, .6667, 8, 9);
    CopyPoint(newshape,  shape, 11,  9);
    InterPoint(newshape, shape, 12, .5,    9, 10);
    InterPoint(newshape, shape, 13, .3333, 10, 11);
    CopyPoint(newshape,  shape, 14, 12);
    CopyPoint(newshape,  shape, 15, 25);
    CopyPoint(newshape,  shape, 16, 24);
    CopyPoint(newshape,  shape, 17, 23);
    CopyPoint(newshape,  shape, 18, 22);
    CopyPoint(newshape,  shape, 19, 27);
    CopyPoint(newshape,  shape, 20, 26);
    CopyPoint(newshape,  shape, 21, 18);
    CopyPoint(newshape,  shape, 22, 17);
    CopyPoint(newshape,  shape, 23, 16);
    CopyPoint(newshape,  shape, 24, 21);
    CopyPoint(newshape,  shape, 25, 20);
    CopyPoint(newshape,  shape, 26, 19);
    CopyPoint(newshape,  shape, 27, 34);
    CopyPoint(newshape,  shape, 28, 32);
    CopyPoint(newshape,  shape, 29, 30);
    CopyPoint(newshape,  shape, 30, 36);
    CopyPoint(newshape,  shape, 31, 38);
    CopyPoint(newshape,  shape, 32, 44);
    CopyPoint(newshape,  shape, 33, 42);
    CopyPoint(newshape,  shape, 34, 40);
    CopyPoint(newshape,  shape, 35, 46);
    CopyPoint(newshape,  shape, 36, 39);
    InterPoint(newshape, shape, 37, .6667, 30, 40);
    newshape(37, IX) = shape(50, IX);
    CopyPoint(newshape,  shape, 38, 50);
    CopyPoint(newshape,  shape, 39, 58);
    CopyPoint(newshape,  shape, 40, 57);
    CopyPoint(newshape,  shape, 41, 56);
    CopyPoint(newshape,  shape, 42, 55);
    CopyPoint(newshape,  shape, 43, 54);
    CopyPoint(newshape,  shape, 44, 48);
    InterPoint(newshape, shape, 45, .3333, 30, 40);
    newshape(45, IX) = shape(48, IX);
    CopyPoint(newshape,  shape, 46, 51);
    CopyPoint(newshape,  shape, 47, 53);
    CopyPoint(newshape,  shape, 48, 59);
    CopyPoint(newshape,  shape, 49, 60);
    CopyPoint(newshape,  shape, 50, 61);
    CopyPoint(newshape,  shape, 51, 62);
    CopyPoint(newshape,  shape, 52, 63);
    CopyPoint(newshape,  shape, 53, 64);
    CopyPoint(newshape,  shape, 54, 65);
    CopyPoint(newshape,  shape, 55, 72);
    CopyPoint(newshape,  shape, 56, 73);
    CopyPoint(newshape,  shape, 57, 74);
    CopyPoint(newshape,  shape, 58, 75);
    CopyPoint(newshape,  shape, 59, 76);
    CopyPoint(newshape,  shape, 60, 69);
    CopyPoint(newshape,  shape, 61, 70);
    CopyPoint(newshape,  shape, 62, 71);
    CopyPoint(newshape,  shape, 63, 66);
    CopyPoint(newshape,  shape, 64, 67);
    CopyPoint(newshape,  shape, 65, 68);
    InterPoint(newshape, shape, 66, .5, 67, 70);
    CopyPoint(newshape,  shape, 67, 52);

#if MOD_A1 || MOD_A || MOD_A_EMU
    const double eyemouth = EyeMouthDist(shape);
    newshape(38, IY) += MAX(1, .05 * eyemouth); // move side of nose down
    newshape(44, IY) += MAX(1, .05 * eyemouth); // move side of nose down
    newshape(46, IY) += MAX(1, .02 * eyemouth); // move down, into nostril
    newshape(47, IY) += MAX(1, .02 * eyemouth); // move down, into nostril
#endif

    return newshape;
}
示例#7
0
static Shape Shape77As20( // return an approximated BioID 20 point shape
    const Shape& shape)   // in: Stasm 77 point shape
{
    CV_Assert(shape.rows == 77);

    Shape newshape(20, 2);

    CopyPoint(newshape, shape,  0, 38);
    CopyPoint(newshape, shape,  1, 39);
    CopyPoint(newshape, shape,  2, 59);
    CopyPoint(newshape, shape,  3, 65);
    CopyPoint(newshape, shape,  4, 18);
    CopyPoint(newshape, shape,  5, 21);
    CopyPoint(newshape, shape,  6, 22);
    CopyPoint(newshape, shape,  7, 25);
    CopyPoint(newshape, shape,  8, 0);
    CopyPoint(newshape, shape,  9, 34);
    CopyPoint(newshape, shape, 10, 30);
    CopyPoint(newshape, shape, 11, 40);
    CopyPoint(newshape, shape, 12, 44);
    CopyPoint(newshape, shape, 13, 12);
    CopyPoint(newshape, shape, 14, 52);
    CopyPoint(newshape, shape, 15, 51);
    CopyPoint(newshape, shape, 16, 53);
    CopyPoint(newshape, shape, 17, 62);
    CopyPoint(newshape, shape, 18, 74);
    CopyPoint(newshape, shape, 19, 6);

#if MOD_A1 || MOD_A || MOD_A_EMU
    const double eyemouth = EyeMouthDist(shape);
    newshape(15, IY) += MAX(1, .02 * eyemouth); // move down, into nostril
    newshape(16, IY) += MAX(1, .02 * eyemouth); // move down, into nostril
#endif

    return newshape;
}