watering
This commit is contained in:
@@ -370,18 +370,20 @@ const Watering = () => {
|
|||||||
<Circle center={[pt.lat, pt.lng]} radius={cov.radius*0.3048} pathOptions={{ color:'#2563eb', fillOpacity:0.2 }} />
|
<Circle center={[pt.lat, pt.lng]} radius={cov.radius*0.3048} pathOptions={{ color:'#2563eb', fillOpacity:0.2 }} />
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
{cov?.kind==='rect' && (
|
{cov?.kind==='rect' && (()=>{
|
||||||
<Rectangle
|
const clat=Number(pt.lat), clng=Number(pt.lng);
|
||||||
bounds={[[
|
const L=cov.length, W=cov.width; const hdg=(Number(pt.sprinkler_heading_degrees||0))*Math.PI/180;
|
||||||
Number(pt.lat) - (cov.width/2)*0.00000274,
|
const Rlat=111320, Rlng=Math.cos(clat*Math.PI/180)*111320;
|
||||||
Number(pt.lng) - (cov.length/2)*0.0000036
|
const hf=L/2*0.3048, wf=W/2*0.3048;
|
||||||
], [
|
const corners=[{x:hf,y:wf},{x:-hf,y:wf},{x:-hf,y:-wf},{x:hf,y:-wf}].map(({x,y})=>{
|
||||||
Number(pt.lat) + (cov.width/2)*0.00000274,
|
const xr=x*Math.cos(hdg)-y*Math.sin(hdg);
|
||||||
Number(pt.lng) + (cov.length/2)*0.0000036
|
const yr=x*Math.sin(hdg)+y*Math.cos(hdg);
|
||||||
]]}
|
const lat=clat + (yr/Rlat);
|
||||||
pathOptions={{ color:'#2563eb', fillOpacity:0.2 }}
|
const lng=clng + (xr/Rlng);
|
||||||
/>
|
return [lat,lng];
|
||||||
)}
|
});
|
||||||
|
return <Polygon positions={corners} pathOptions={{ color:'#2563eb', fillOpacity:0.2 }} />;
|
||||||
|
})()}
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
@@ -394,25 +396,3 @@ const Watering = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default Watering;
|
export default Watering;
|
||||||
const onSelectPoint = (pt) => {
|
|
||||||
setSelectedPointId(pt.id);
|
|
||||||
setEditForm({
|
|
||||||
durationMinutes: pt.duration_minutes || 0,
|
|
||||||
mountType: pt.sprinkler_mount,
|
|
||||||
sprinklerHeadType: pt.sprinkler_head_type,
|
|
||||||
gpm: Number(pt.sprinkler_gpm||0),
|
|
||||||
throwFeet: Number(pt.sprinkler_throw_feet||0),
|
|
||||||
degrees: Number(pt.sprinkler_degrees||360),
|
|
||||||
lengthFeet: Number(pt.sprinkler_length_feet||0),
|
|
||||||
widthFeet: Number(pt.sprinkler_width_feet||0),
|
|
||||||
headingDegrees: Number(pt.sprinkler_heading_degrees||0)
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const updatePointField = async (id, patch) => {
|
|
||||||
try {
|
|
||||||
const r = await wateringAPI.updatePoint(id, patch);
|
|
||||||
const np = r.data?.data?.point;
|
|
||||||
setPoints(prev => prev.map(p=> p.id===id? np: p));
|
|
||||||
} catch(e){ toast.error('Failed to update point'); }
|
|
||||||
};
|
|
||||||
|
|||||||
Reference in New Issue
Block a user