Opened 18 years ago

Closed 18 years ago

Last modified 18 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

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

comment:1 by waltweltonlair, 18 years ago

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 by waltweltonlair, 18 years ago

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 by waltweltonlair, 18 years ago

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

comment:4 by rexszeto, 18 years ago

External ID: 925183

comment:5 by waltweltonlair, 18 years ago

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 by waltweltonlair, 18 years ago

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 by waltweltonlair, 18 years ago

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 by waltweltonlair, 18 years ago

Resolution: fixed
Status: assignedclosed

comment:9 by jbirch, 18 years ago

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

comment:10 by anonymous, 18 years ago

Cc: jbirch added

comment:11 by waltweltonlair, 18 years ago

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

Note: See TracTickets for help on using tickets.