Example #1
0
static VALUE method_geometry_intersects(VALUE self, VALUE rhs)
{
  VALUE result;
  RGeo_GeometryData* self_data;
  const GEOSGeometry* self_geom;
  const GEOSGeometry* rhs_geom;
  char val;
#ifdef RGEO_GEOS_SUPPORTS_PREPARED1
  const GEOSPreparedGeometry* prep;
#endif

  result = Qnil;
  self_data = RGEO_GEOMETRY_DATA_PTR(self);
  self_geom = self_data->geom;
  if (self_geom) {
    rhs_geom = rgeo_convert_to_geos_geometry(self_data->factory, rhs, Qnil);
    if (rhs_geom) {
#ifdef RGEO_GEOS_SUPPORTS_PREPARED1
      prep = rgeo_request_prepared_geometry(self_data);
      if (prep)
        val = GEOSPreparedIntersects_r(self_data->geos_context, prep, rhs_geom);
      else
#endif
        val = GEOSIntersects_r(self_data->geos_context, self_geom, rhs_geom);
      if (val == 0) {
        result = Qfalse;
      }
      else if (val == 1) {
        result = Qtrue;
      }
    }
  }
  return result;
}
Example #2
0
  bool LabelPosition::crossesLine( PointSet* line ) const
  {
    if ( !mGeos )
      createGeosGeom();

    if ( !line->mGeos )
      line->createGeosGeom();

    GEOSContextHandle_t geosctxt = geosContext();
    try
    {
      if ( GEOSPreparedIntersects_r( geosctxt, line->preparedGeom(), mGeos ) == 1 )
      {
        return true;
      }
      else if ( nextPart )
      {
        return nextPart->crossesLine( line );
      }
    }
    catch ( GEOSException &e )
    {
      QgsMessageLog::logMessage( QObject::tr( "Exception: %1" ).arg( e.what() ), QObject::tr( "GEOS" ) );
      return false;
    }

    return false;
  }
Example #3
0
  bool LabelPosition::isInConflictSinglePart( LabelPosition* lp )
  {
    if ( !mGeos )
      createGeosGeom();

    if ( !lp->mGeos )
      lp->createGeosGeom();

    GEOSContextHandle_t geosctxt = geosContext();
    bool result = ( GEOSPreparedIntersects_r( geosctxt, preparedGeom(), lp->mGeos ) == 1 );
    return result;
  }
Example #4
0
  bool LabelPosition::isInConflictSinglePart( LabelPosition* lp )
  {
    if ( !mGeos )
      createGeosGeom();

    if ( !lp->mGeos )
      lp->createGeosGeom();

    GEOSContextHandle_t geosctxt = geosContext();
    try
    {
      bool result = ( GEOSPreparedIntersects_r( geosctxt, preparedGeom(), lp->mGeos ) == 1 );
      return result;
    }
    catch ( GEOSException &e )
    {
      QgsMessageLog::logMessage( QObject::tr( "Exception: %1" ).arg( e.what() ), QObject::tr( "GEOS" ) );
      return false;
    }
  }
Example #5
0
  bool LabelPosition::crossesLine( PointSet* line ) const
  {
    if ( !mGeos )
      createGeosGeom();

    if ( !line->mGeos )
      line->createGeosGeom();

    GEOSContextHandle_t geosctxt = geosContext();
    if ( GEOSPreparedIntersects_r( geosctxt, line->preparedGeom(), mGeos ) == 1 )
    {
      return true;
    }
    else if ( nextPart )
    {
      return nextPart->crossesLine( line );
    }

    return false;
  }