Akce v Chrudim
10. duben 2041
Zkuste jiný den nebo se vraťte na přehled celého měsíce.
Zobrazit kalendářfunction nearbyArticles( object $article, float $latitude, float $longitude, int $limit = 6, float $radiusKm = 25 ): array { $stmt = db()->prepare(" SELECT a.id, a.candidate_id, a.title, a.slug, a.perex, a.content, a.source_name, a.source_url, a.address, a.latitude, a.longitude, a.published, a.is_pr, a.published_at, a.created, a.updated, c.topic, c.place_name, c.municipality, c.territory_id, c.district, c.region, c.region_id, c.type, c.importance, m.code AS municipality_code, m.slug AS municipality_slug, r.slug AS region_slug, CASE WHEN NULLIF( TRIM(a.address), '' ) IS NOT NULL THEN a.latitude ELSE COALESCE( a.latitude, m.latitude ) END AS effective_latitude, CASE WHEN NULLIF( TRIM(a.address), '' ) IS NOT NULL THEN a.longitude ELSE COALESCE( a.longitude, m.longitude ) END AS effective_longitude, ( 6371 * ACOS( LEAST( 1, GREATEST( -1, COS( RADIANS(?) ) * COS( RADIANS( CASE WHEN NULLIF( TRIM(a.address), '' ) IS NOT NULL THEN a.latitude ELSE COALESCE( a.latitude, m.latitude ) END ) ) * COS( RADIANS( CASE WHEN NULLIF( TRIM(a.address), '' ) IS NOT NULL THEN a.longitude ELSE COALESCE( a.longitude, m.longitude ) END ) - RADIANS(?) ) + SIN( RADIANS(?) ) * SIN( RADIANS( CASE WHEN NULLIF( TRIM(a.address), '' ) IS NOT NULL THEN a.latitude ELSE COALESCE( a.latitude, m.latitude ) END ) ) ) ) ) ) AS distance_km FROM articles a JOIN article_candidates c ON c.id = a.candidate_id LEFT JOIN territories m ON m.id = c.territory_id AND m.type = 'municipality' LEFT JOIN territories r ON r.id = c.region_id AND r.type = 'region' WHERE a.published = 1 AND a.id != ? AND ( ( NULLIF( TRIM(a.address), '' ) IS NOT NULL AND a.latitude IS NOT NULL AND a.longitude IS NOT NULL ) OR ( NULLIF( TRIM(a.address), '' ) IS NULL AND ( ( a.latitude IS NOT NULL AND a.longitude IS NOT NULL ) OR ( m.latitude IS NOT NULL AND m.longitude IS NOT NULL ) ) ) ) HAVING distance_km <= ? ORDER BY distance_km ASC, COALESCE( a.published_at, a.created ) DESC, a.id DESC LIMIT ? "); $stmt->bindValue( 1, $latitude ); $stmt->bindValue( 2, $longitude ); $stmt->bindValue( 3, $latitude ); $stmt->bindValue( 4, (int) $article->id, PDO::PARAM_INT ); $stmt->bindValue( 5, $radiusKm ); $stmt->bindValue( 6, $limit, PDO::PARAM_INT ); $stmt->execute(); return $stmt->fetchAll(); } function nearbyArticlesForMunicipality( object $municipality, int $limit = 6, float $radiusKm = 25 ): array { if ( $municipality->latitude === null || $municipality->longitude === null ) { return []; } $latitude = (float) $municipality->latitude; $longitude = (float) $municipality->longitude; $stmt = db()->prepare(" SELECT a.id, a.candidate_id, a.title, a.slug, a.perex, a.content, a.source_name, a.source_url, a.address, a.latitude, a.longitude, a.published, a.is_pr, a.published_at, a.created, a.updated, c.topic, c.place_name, c.municipality, c.territory_id, c.district, c.region, c.region_id, c.type, c.importance, m.code AS municipality_code, m.slug AS municipality_slug, r.slug AS region_slug, CASE WHEN NULLIF( TRIM(a.address), '' ) IS NOT NULL THEN a.latitude ELSE COALESCE( a.latitude, m.latitude ) END AS effective_latitude, CASE WHEN NULLIF( TRIM(a.address), '' ) IS NOT NULL THEN a.longitude ELSE COALESCE( a.longitude, m.longitude ) END AS effective_longitude, ( 6371 * ACOS( LEAST( 1, GREATEST( -1, COS( RADIANS(?) ) * COS( RADIANS( CASE WHEN NULLIF( TRIM(a.address), '' ) IS NOT NULL THEN a.latitude ELSE COALESCE( a.latitude, m.latitude ) END ) ) * COS( RADIANS( CASE WHEN NULLIF( TRIM(a.address), '' ) IS NOT NULL THEN a.longitude ELSE COALESCE( a.longitude, m.longitude ) END ) - RADIANS(?) ) + SIN( RADIANS(?) ) * SIN( RADIANS( CASE WHEN NULLIF( TRIM(a.address), '' ) IS NOT NULL THEN a.latitude ELSE COALESCE( a.latitude, m.latitude ) END ) ) ) ) ) ) AS distance_km FROM articles a JOIN article_candidates c ON c.id = a.candidate_id LEFT JOIN territories m ON m.id = c.territory_id AND m.type = 'municipality' LEFT JOIN territories r ON r.id = c.region_id AND r.type = 'region' WHERE a.published = 1 /* * Nechceme znovu články * přímo z aktuální obce. */ AND c.territory_id != ? AND ( ( NULLIF( TRIM(a.address), '' ) IS NOT NULL AND a.latitude IS NOT NULL AND a.longitude IS NOT NULL ) OR ( NULLIF( TRIM(a.address), '' ) IS NULL AND ( ( a.latitude IS NOT NULL AND a.longitude IS NOT NULL ) OR ( m.latitude IS NOT NULL AND m.longitude IS NOT NULL ) ) ) ) HAVING distance_km <= ? ORDER BY distance_km ASC, COALESCE( a.published_at, a.created ) DESC, a.id DESC LIMIT ? "); $stmt->bindValue( 1, $latitude ); $stmt->bindValue( 2, $longitude ); $stmt->bindValue( 3, $latitude ); $stmt->bindValue( 4, (int) $municipality->id, PDO::PARAM_INT ); $stmt->bindValue( 5, $radiusKm ); $stmt->bindValue( 6, $limit, PDO::PARAM_INT ); $stmt->execute(); return $stmt->fetchAll(); }
10. duben 2041
Zkuste jiný den nebo se vraťte na přehled celého měsíce.
Zobrazit kalendář