MapGuide Open Source:  Home |  Download |  Internals

Ticket #35 (closed defect: fixed)

Opened 1 year ago

Last modified 1 year ago

Error calling MgWktReaderWriter.Write from PHP

Reported by: waltweltonlair Assigned to: waltweltonlair
Priority: high Milestone: 1.2
Component: Web API Version: 1.2.0
Severity: major Keywords:
Cc: jbirch External ID: 925183

Description

Reported by Jason Birch:

This:

http://www.jasonbirch.com/temp/test.phps

Gives me errors either way I run it (UTM to LL or LL to UTM).

Fatal error: Type error in argument 1 of MgWktReaderWriter_Write. Expected _p_MgGeometry in C:\Program Files\MapGuideOpenSource\WebServerExtensions\Apache2\htdocs\parcels\test .php on line 42

It works just fine if I remove the transform as the second optional parameter to the WKT reader. The thing is that these same transforms are working correctly on features that I'm reading directly from a FeatureSource. So what am I missing?

This is just a test case. What I really want to do with the transformed bounding box is something like:

$queryOptions->SetSpatialFilter("Geometry", $bboxUTM10, MgFeatureSpatialOperations::EnvelopeIntersects);

I'm basically trying to take in a BBOX in LL, transform it to UTM10, then use its envelope as a spatial filter.

Change History

04/05/07 06:07:18 changed by waltweltonlair

Paul Spencer also reported a similar problem:

Hi all,

In the API documentation, there are three potential signatures
for the generateplot function.  It seems that the second signature
will not work in PHP due to an error in the swig bindings:

virtual !MgByteReader * !GeneratePlot (!MgMap *map,
    !MgCoordinate *center, double scale,
    !MgPlotSpecification *plotSpec,
    !MgLayout *layout,
    !MgDwfVersion *dwfVersion)

Calling this function results in a PHP Fatal error:
Arguments passed did not match any overload for method _wrap_MgMappingService_GeneratePlot

The other signatures seem to work.

04/05/07 06:09:23 changed by waltweltonlair

The code which does these checks is generated by SWIG (PhpApi/MgApi_wrap.cpp), and it wouldn't be too hard to debug into it to see what's going on. Unfortunately I'm not set up for PHP at the moment - maybe someone else can give this a try?

There actually is a small typo in one of our SWIG input files (MapGuideApiGen.xml):

    ...
    <Header path="../../../Common/Geometry/Transform.h"/>
    <Header path="../../../Common/Geometry/GeometricEntity.h"/>/>
    <Header path="../../../Common/Geometry/Geometry.h"/> 
    ...

There's an extra closing bracket right before Geometry.h where the MgGeometry type is defined.

Unfortunately fixing this didn't make any difference as far as the autogenerated SWIG code, so the problem must lie somewhere else.

04/05/07 06:14:48 changed by waltweltonlair

The MapGuideApiGen.xml typo was fixed with http://trac.osgeo.org/mapguide/changeset/1472.

04/05/07 12:48:17 changed by rexszeto

  • external_id set to 925183.

05/07/07 17:49:15 changed by waltweltonlair

Well, it's pretty obvious now why this fails... Here's the implementation of Read with a transform:

MgGeometry?* MgWktReaderWriter::Read(CREFSTRING wkt, MgTransform?* transform) {

return NULL;

}

Let me see what's involved to implement this...

05/07/07 18:46:58 changed by waltweltonlair

  • status changed from new to assigned.
  • owner set to waltweltonlair.

This is pretty straightforward to fix. Here's the output now of your test.phps code:

POLYGON ((-123.98850060910458 49.207560917062843, -123.98867996880281 49.2165548 060910458 49.207560917062843))

05/07/07 18:50:04 changed by waltweltonlair

Might help if I paste the full string...

POLYGON ((-123.98850060910458 49.207560917062843, -123.98867996880281 49.216554860874673, -123.97495040402514 49.216671569297716, -123.97477353408442 49.207677588695184, -123.98850060910458 49.207560917062843))

05/07/07 19:21:00 changed by waltweltonlair

  • status changed from assigned to closed.
  • resolution set to fixed.

05/16/07 00:40:46 changed by jbirch

Thanks Walt,

I should have added myself as a CC...

Is there a different ticket in for Paul's report, or should we pull that out into a new one?

J

05/16/07 00:41:47 changed by anonymous

  • cc set to jbirch.

05/16/07 05:13:30 changed by waltweltonlair

Paul's GeneratePlot bug is in http://trac.osgeo.org/mapguide/ticket/123.