예제 #1
0
OGRLineString* OGRMSSQLGeometryParser::ReadLineString(int iShape)
{
    int iFigure, iPoint, iNextPoint, i;
    iFigure = FigureOffset(iShape);

    OGRLineString* poLineString = new OGRLineString();
    iPoint = PointOffset(iFigure);
    iNextPoint = NextPointOffset(iFigure);
    poLineString->setNumPoints(iNextPoint - iPoint);
    i = 0;
    while (iPoint < iNextPoint)
    {
        if (nColType == MSSQLCOLTYPE_GEOGRAPHY)
        {
            if ( chProps & SP_HASZVALUES )
                poLineString->setPoint(i, ReadY(iPoint), ReadX(iPoint), ReadZ(iPoint) );
            else
                poLineString->setPoint(i, ReadY(iPoint), ReadX(iPoint) );
        }
        else
        {
            if ( chProps & SP_HASZVALUES )
                poLineString->setPoint(i, ReadX(iPoint), ReadY(iPoint), ReadZ(iPoint) );
            else
                poLineString->setPoint(i, ReadX(iPoint), ReadY(iPoint) );
        }

        ++iPoint;
        ++i;
    }

    return poLineString;
}
예제 #2
0
void QgsMssqlGeometryParser::ReadLineString( int iShape )
{
  int iFigure, iPoint, iNextPoint, i, iCount;
  iFigure = FigureOffset( iShape );

  iPoint = PointOffset( iFigure );
  iNextPoint = NextPointOffset( iFigure );
  iCount = iNextPoint - iPoint;
  if ( iCount <= 0 )
    return;
  // 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 length
  CopyBytes( &iCount, 4 );
  // copy coordinates
  i = 0;
  while ( iPoint < iNextPoint )
  {
    CopyCoordinates( iPoint );
    ++iPoint;
    ++i;
  }
}
예제 #3
0
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);
    }
}
예제 #4
0
OGRPolygon* OGRMSSQLGeometryParser::ReadPolygon(int iShape)
{
    int iFigure, iPoint, iNextPoint, i;
    int iNextFigure = NextFigureOffset(iShape);
    
    OGRPolygon* poPoly = new OGRPolygon();
    for (iFigure = FigureOffset(iShape); iFigure < iNextFigure; iFigure++)
    {
        OGRLinearRing* poRing = new OGRLinearRing();
        iPoint = PointOffset(iFigure);
        iNextPoint = NextPointOffset(iFigure);
        poRing->setNumPoints(iNextPoint - iPoint);
        i = 0;
        while (iPoint < iNextPoint)
        {
            if ( chProps & SP_HASZVALUES )
                poRing->setPoint(i, ReadX(iPoint), ReadY(iPoint), ReadZ(iPoint) );
            else
                poRing->setPoint(i, ReadX(iPoint), ReadY(iPoint) );

            ++iPoint;
            ++i;
        }
        poPoly->addRingDirectly( poRing );
    }
    return poPoly;
}
예제 #5
0
mapnik::geometry::polygon<double> sqlserver_geometry_parser::ReadPolygon(int iShape)
{
	mapnik::geometry::polygon<double> geom;
    int iNextFigure = NextFigureOffset(iShape);
    
    for (int iFigure = FigureOffset(iShape); iFigure < iNextFigure; iFigure++) {
		mapnik::geometry::linear_ring<double> ring;
		int iPoint = PointOffset(iFigure);
        int iNextPoint = NextPointOffset(iFigure);
        while (iPoint < iNextPoint) {
            if (colType == Geography) {
                ring.emplace_back(ReadY(iPoint), ReadX(iPoint));
            } else {
                ring.emplace_back(ReadX(iPoint), ReadY(iPoint));
            }

            ++iPoint;
        }
		if (iFigure == 0) {
			geom.set_exterior_ring(std::move(ring));
		} else {
			geom.add_hole(std::move(ring));
		}
	}
    return geom;
}
예제 #6
0
mapnik::geometry::line_string<double> sqlserver_geometry_parser::ReadLineString(int iShape)
{
	mapnik::geometry::line_string<double> geom;
    int iFigure = FigureOffset(iShape);

    int iPoint = PointOffset(iFigure);
    int iNextPoint = NextPointOffset(iFigure);
    while (iPoint < iNextPoint) {
        if (colType == Geography) {
			geom.emplace_back(ReadY(iPoint), ReadX(iPoint));
        } else {
			geom.emplace_back(ReadX(iPoint), ReadY(iPoint));
        }
        
        ++iPoint;
    }

    return geom;
}
예제 #7
0
OGRMultiPoint* OGRMSSQLGeometryParser::ReadMultiPoint(int iShape)
{
    int iFigure, iPoint, iNextPoint;
    iFigure = FigureOffset(iShape);

    OGRMultiPoint* poMultiPoint = new OGRMultiPoint();
    iNextPoint = NextPointOffset(iFigure);
    for (iPoint = PointOffset(iFigure); iPoint < iNextPoint; iPoint++)
    {
        OGRPoint* poPoint;
        
        if ( chProps & SP_HASZVALUES )
            poPoint = new OGRPoint( ReadX(iPoint), ReadY(iPoint), ReadZ(iPoint) );
        else
            poPoint = new OGRPoint( ReadX(iPoint), ReadY(iPoint) );

        if ( poPoint )
            poMultiPoint->addGeometryDirectly( poPoint );
    }

    return poMultiPoint;
}
예제 #8
0
void QgsMssqlGeometryParser::ReadPolygon( int iShape )
{
  int iFigure, iPoint, iNextPoint, iCount, i;
  int iNextFigure = NextFigureOffset( iShape );
  iCount = iNextFigure - FigureOffset( iShape );
  if ( iCount <= 0 )
    return;
  // copy byte order
  CopyBytes( &chByteOrder, 1 );
  // copy type
  int wkbType;
  if ( chProps & SP_HASZVALUES )
    wkbType = QGis::WKBPolygon25D;
  else
    wkbType = QGis::WKBPolygon;
  CopyBytes( &wkbType, 4 );
  // copy ring count
  CopyBytes( &iCount, 4 );
  // copy rings
  for ( iFigure = FigureOffset( iShape ); iFigure < iNextFigure; iFigure++ )
  {
    iPoint = PointOffset( iFigure );
    iNextPoint = NextPointOffset( iFigure );
    iCount = iNextPoint - iPoint;
    if ( iCount <= 0 )
      continue;
    // copy point count
    CopyBytes( &iCount, 4 );
    // copy coordinates
    i = 0;
    while ( iPoint < iNextPoint )
    {
      CopyCoordinates( iPoint );
      ++iPoint;
      ++i;
    }
  }
}