PostgreSQL SelectFeatures

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

PostgreSQL SelectFeatures

Kori Maleski
I am having an issue selecting features stored in PostgreSQL.

MapGuide 2.5.2 and MapGuide 3.0

PHP showclass.php or buffer.php for example, will return the MgFeatureReader with class definition etc, but without any features.

.NET  MgFeatureReader is returned fully populated with features.


Trying to use fusion (which defaults to php).

Anybody else have this issue?  Work around?


Kori Maleski
Reply | Threaded
Open this post in threaded view
|

Re: PostgreSQL SelectFeatures

Kori Maleski
This PostgreSQL issue also occurs when previewing FeatureSources in Maestro or AIMS Studio.

Schema and class display fine.

View Feature shows features in map fine.

View Data shows columns with no records.


An application with .Net mg-desktop has no issue here.  Just seems to be something with PHP.

Possibly something with table structure in Postgres?  
Reply | Threaded
Open this post in threaded view
|

Re: PostgreSQL SelectFeatures

Kori Maleski
Argh.

It fails due to a column being blob/hexBinary.


Reply | Threaded
Open this post in threaded view
|

Re: PostgreSQL SelectFeatures

Kori Maleski
To get the Fusion buffer (or other widgets) to work with tables that contain incompatible column data types (PostgreSQL  or any FDO FeatureSource for that matter):

Modify Buffer.php so as to select compatible columns:

...

            $featureClassName = $selLayer->GetFeatureClassName();
            $filter = $sel->GenerateFilter($selLayer, $featureClassName);
            if($filter == "")
                continue;

               
            $query = new MgFeatureQueryOptions();
            $query->SetFilter($filter);

                    $classDef = $selLayer->GetClassDefinition();
                        $geomPropName = $classDef->GetDefaultGeometryPropertyName();
                        $propertyList = $classDef->GetProperties();

                    for($i=0; $i<$propertyList->GetCount(); $i++)
                        {
                                $propertyDef = $propertyList->GetItem($i);
                                $property = $propertyList->GetItem($i)->GetName();

                                if(($property!=$geomPropName)&&($propertyDef->GetPropertyType()==100))
                                {
                                        $propertyType = $propertyList->GetItem($i)->GetDataType();
                                        switch ($propertyType) {
                                                case MgPropertyType::Boolean :
                                                        $query->AddFeatureProperty($property);
                                                        break;
                                                case MgPropertyType::Byte :
                                                        $query->AddFeatureProperty($property);
                                                        break;
                                                case MgPropertyType::DateTime :
                                                        $query->AddFeatureProperty($property);
                                                        break;
                                                case MgPropertyType::Single :
                                                        $query->AddFeatureProperty($property);
                                                        break;
                                                case MgPropertyType::Double :
                                                        $query->AddFeatureProperty($property);
                                                        break;
                                                case MgPropertyType::Int16 :
                                                        $query->AddFeatureProperty($property);
                                                        break;
                                                case MgPropertyType::Int32 :
                                                        $query->AddFeatureProperty($property);
                                                        break;
                                                case MgPropertyType::Int64 :
                                                        $query->AddFeatureProperty($property);
                                                        break;
                                                case MgPropertyType::String :
                                                        $query->AddFeatureProperty($property);
                                                        break;
                                        }
                                }else if($property==$geomPropName){
                                        $query->AddFeatureProperty($property);
                                }
                        }
                               
            $featureSource = new MgResourceIdentifier($selLayer->GetFeatureSourceId());

            $features = $featureSrvc->SelectFeatures($featureSource, $featureClassName, $query);

            if($features->ReadNext())

...


The same would have to be done in the Mapguide/Web/schemareport folder for showclass.php as well as other instances where SelectFeatures is utilized.



Reply | Threaded
Open this post in threaded view
|

Re: PostgreSQL SelectFeatures

Jackie Ng
Please note that the upcoming beta 2 release of MapGuide Open Source 3.1 will now use explicit property lists for AJAX/Fusion viewer functionality that needs to do feature queries.

- Jackie