错误:是/ 2:在prolog

时间:2015-07-31 13:33:17

标签: prolog instantiation-error

我是Prolog的新用户,我正在尝试缩放和转换地图中的坐标,但是在比例和变换RULE 时出现错误“没有充分实例化”。这是我的规则,似乎论证没有充分实例化,请你解决我们如何解决这个问题的解决方案。它接缝问题是在规模和变换规则,我使用“IS”运算符

transform_all :-
   forall(
      representation(Id, Geom),
      (  transform(Geom, TGeom),
         record_transformed_rep(Id, TGeom)
      )
   ).
transform_all :-
    forall(
       (  representation(Id, Geom),
          not(transformed_rep(Id))
       ),
       (  transform(Geom, TGeom),
          record_transformed_rep(Id, TGeom)
       )
    ).

%transformation
transform(Geom, TGeom) :-
   scale(Geom, value(10000), SGeom),
   translate(SGeom, value(-7.5, -51.9), TGeom).

%record_the_transformed_geometries
record_transformed_rep(Id, TGeom) :-
   retractall(representation(Id, _)),
   assert(representation(Id, TGeom)),
   assert(transformed_rep(Id)).  %% flag to avoid infinite loop

%scale_and_translate_metric_Map
scale(point(X,Y), value(V), point(Sx,Sy)) :-
   Sx is X * V,
   Sy is Y * V.

scale(polyline([]), value(_), polyline([])).
scale(polyline([P|R]), value(V), polyline([Sp|Sr])) :-
   scale(P,value(V),Sp),
   scale(polyline(R), value(V), polyline(Sr)).

%translate_coordinate_of_metric_map
translate(point(X,Y), value(Dx,Dy), point(Sx,Sy)) :-
   Sx is X + Dx,
   Sy is Y + Dy.

translate(polyline([]), value(_,_), polyline([])).
translate(polyline([P|R]), value(Dx,Dy), polyline([Sp|Sr])) :-
   translate(P,value(Dx,Dy),Sp),
   translate(polyline(R), value(Dx,Dy), polyline(Sr)). 

0 个答案:

没有答案