Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#35 closed defect (fixed)

Error calling MgWktReaderWriter.Write from PHP

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


Reported by Jason Birch:


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 (11)

comment:1 Changed 12 years ago 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.

comment:2 Changed 12 years ago 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.

comment:3 Changed 12 years ago by waltweltonlair

The MapGuideApiGen.xml typo was fixed with

comment:4 Changed 12 years ago by rexszeto

External ID: 925183

comment:5 Changed 12 years ago 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...

comment:6 Changed 12 years ago by waltweltonlair

Owner: set to waltweltonlair
Status: newassigned

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))

comment:7 Changed 12 years ago 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))

comment:8 Changed 12 years ago by waltweltonlair

Resolution: fixed
Status: assignedclosed

comment:9 Changed 12 years ago 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?


comment:10 Changed 12 years ago by anonymous

Cc: jbirch added

comment:11 Changed 12 years ago by waltweltonlair

Paul's GeneratePlot bug is in

Note: See TracTickets for help on using tickets.