Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8490819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:14:13+00:00 2026-06-10T22:14:13+00:00

I have a public facing app that is based on Postgres and PostGIS. I

  • 0

I have a public facing app that is based on Postgres and PostGIS.

I have tried Googling for hours but have been unable to find any documentation that can show some basic geospatial stuff like getting distance between two points using Doctrine2. Not being able to use an ORM is a big deal for me in terms of determining my database of choice.

Can someone show me a basic example of lets say showing all points within a radius of lets say 10 miles using Doctrine?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T22:14:15+00:00Added an answer on June 10, 2026 at 10:14 pm

    I wrote an article on my blog, explaining how to use Doctrine 2 (version 2.2+) and Postgis. The article is in French, but the code is PHP, which an international language :

    http://web.archive.org/web/20161118060448/http://blog.fastre.info:80/2012/02/doctrine2-2-2-et-types-geographiques/

    As you will see, importing data from database to an object need some conversion:

    1. The data are converted to geojson by postgis (json is readable by php, using json_decode function)
    2. The data are transformed into a Point object

    And from the object’s world to database:

    1. The object Point is converted into WKT. Why WKT and not json ? Because Postgis has a ST_GeogFromWKT function, but not (yet) a ST_GeogFromGeoJson function.
    2. The data are inserted into the database.

    I also wrote a custom DQL function class which dealt with the “covered” operation in DQL queries. This is not exactly what you ask, but you may inspire from this and adapt the code.

    namespace Progracqteur\WikipedaleBundle\Resources\Doctrine\Functions;
    
    use Doctrine\ORM\Query\AST\Functions\FunctionNode;
    use Doctrine\ORM\Query\Lexer;
    
    /**
    *
    * @author Julien Fastré <julien arobase fastre point info>
    */
    class Covers extends FunctionNode {
    
        private $polygon = null;
        private $point = null;
    
    
        public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) {
            return 'ST_Covers('.$this->polygon->dispatch($sqlWalker).', '.$this->point->dispatch($sqlWalker).')';
        }
    
        public function parse(\Doctrine\ORM\Query\Parser $parser) {
    
            $parser->match(Lexer::T_IDENTIFIER);
            $parser->match(Lexer::T_OPEN_PARENTHESIS);
    
            $this->polygon = $parser->StringExpression();
    
            $parser->match(Lexer::T_COMMA);
    
            $this->point = $parser->StringPrimary();
    
            $parser->match(Lexer::T_CLOSE_PARENTHESIS);
    
        }
    }
    

    and this function is added to doctrine using app/config/config.yml :

            dql:
              string_functions:
                covers: Progracqteur\WikipedaleBundle\Resources\Doctrine\Functions\Covers
    

    Be careful: to use this function, you will have to create other functions which will use the ‘ST_FromWKT’ function before, and convert your point to WKT in your getSql (using the __toString function ?). I did not need it in my application, so I do not have code for this to present to you.

    This is an example of using my function : ($entity->getPolygon() return the postgis’s string, without any conversion – i do not need to dealt with a polygon’s object in my app.)

    $em->createQuery('SELECT p from MyEntity p where covers(:polygon, p.geom) = true)
                ->setParameter('polygon', $entity->getPolygon());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a public facing website that has been receiving a number of SQL
I have a public facing interface that I'm trying to map two different enumerations
I have a public facing web page in .Net that I would like to
I have two apps in my Django project: a public-facing app, and a management
ASP.NET - IIS 6 - we currently have a public-facing site that has a
I have implemented ActionBar Tab in my app. But I am facing one issue
I am working on a basic app that has a public facing form (for
This if for an internal CMS, so it's not public facing. I have my
I have public and private keys in separate .pem files that I would need
I am totally new to WPF, I have created a simple WPF app that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.