Ticket #35 (closed defect: fixed)

Opened 5 years ago

Last modified 5 years ago

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

Changed 5 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.

Changed 5 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.

Changed 5 years ago by waltweltonlair

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

Changed 5 years ago by rexszeto

  • external_id set to 925183

Changed 5 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...

Changed 5 years ago by waltweltonlair

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

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

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

Changed 5 years ago by waltweltonlair

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

Changed 5 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?

J

Changed 5 years ago by anonymous

  • cc jbirch added

Changed 5 years ago by waltweltonlair

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

Note: See TracTickets for help on using tickets.